According to the official plugins tutorial, I just copied the code block into the plugins folder, then added the plugin in nuxt.config.js and reported an error.
Version: [email protected]
Here is the screenshot:


@kevinmarrec
@lenvonsam try typescript 3.6 as quick workardound, I saw some issues related to nuxt and typescript 3.7. LMK if it helped you.
@lenvonsam Can you confirm it works with TypeScript 3.6 ? Thanks !
Should the module type declarations be in a myPlugin.d.ts?
Yes. This is a docs issue, not a build one.
Though note that it is an eslint error rather than a TypeScript build error. See here for example.
Still, I would think you want to put declarations in .d.ts files. I'll put in a PR, though happy to be overruled if it's simpler.
@danielroe Can the error be fixed with some eslint rule ? The thing is that this lint error doesn't show up with 3.6
@kevinmarrec This is not associated with an upgrade to TypeScript 3.7 as I can replicate it with 3.6.
The issue is the babel-eslint parser, which is installed out of the box by create-nuxt-app, and which has a number of problems with TypeScript. The first thing I do in any new project is replace it:
yarn add --dev @typescript-eslint/parser
... and then edit .eslintrc.js:
module.exports = {
...
parserOptions: {
parser: "@typescript-eslint/parser"
},
};
bash
yarn eslint '**/*.{vue,ts,js}'
.eslintrc.js.I propose adding some info in docs about correct eslint configuration, if it doesn't already exist.
Edit: docs are correct :smiley:
Alright so it never really has been an issue, right ? Also there's https://github.com/nuxt/create-nuxt-app/pull/328 nearly ready that will fix it around CNA (https://github.com/nuxt/create-nuxt-app/pull/328/files#diff-9fd823e96cf162b0ef4dd75d806e4c4eR12)
Can we close this then ?
Agreed. Yes, this can be closed.
Most helpful comment
@kevinmarrec This is not associated with an upgrade to TypeScript 3.7 as I can replicate it with 3.6.
The issue is the
babel-eslintparser, which is installed out of the box bycreate-nuxt-app, and which has a number of problems with TypeScript. The first thing I do in any new project is replace it:... and then edit
.eslintrc.js: