-
-
Notifications
You must be signed in to change notification settings - Fork 427
[Fix/Feat] Improvements to recently merged typescript-build support #448
Comments
Nice. I had done some of this in my PR to the original dev before merging here: https://github.com/ChangJoo-Park/create-nuxt-app/pull/1
|
Yes, it spreads a bit too much for a single issue, but I thought some points needed a bit of discussion before considering a PR. For example:
That said, I somehow missed your PR and I see that some points are already addressed there. Maybe some of the other proposals could be included in #449? I'd be happy to move the discussion there and close this. I'll check it again Monday, see what else you got planned. |
I'm working on the other parts of the PR right now. See the latest comment for a summary of your issues and the fixes for them. |
Good stuff! I'm closing this issue in favor of #449. We can continue the discussion there. |
I'd like to raise an issue here, for future reference, about a few improvements that I think could be made after the recently merged PR #328.
I have created a new app with the below typescript support options and these are the things I found that (IMHO) can be fixed or improved.
Fixes
[Fix] File XXX is not a module (Vetur error)
Update: There is now a PR vuejs/vetur#1806 addressing this issue.
This has been reported in vuejs/vetur#1187 and vuejs/vetur#1709. Any component that does not export a default vue instance within the
script
tags, causes the following error:pages/index.vue
For now the workaround is to export an empty instance.
components/Logo.vue
[Fix] Remove linting of unused vars
In
nuxt.config.js
,eslint
will output the following errors forconfig
andctx
in the extend webpack config section:To fix it, we could either remove the empty method, add them to the ignore pattern or switch off the
@typescript-eslint/no-unused-vars
rule. For example:[Fix] Do not use the base ESLint indent rule
This has already been reported in nuxt/eslint#76. Using the base eslint
indent
rule causes, among other inconsistencies, the following errorMy initial fix was to switch off the base
indent
rule and usevue/script-indent
instead.However, for this to work in
*.ts
files and not conflict with vue rules, I believe the proper configuration could be to use@typescript-eslint/no-indent
andvue/script-indent
override rules, for*.ts
and*.vue
files, respectively.Features
[Feat] Add TypeScript linting to package.json scripts
Not really an issue (though it might be in CI), since we are all used to have editor linting support. However, to lint
*.ts
files from the console, I believe thelint
script inpackage.json
needs to be aware of the extension.[Feat] Add TypeScript support to Jest test files
In
jest.config.ts
there is support for*.ts
transforms, but*.spec.ts
files are not supported unless@types/jest
is installed and the vue module is declared, for example intypes/vue.shims.d.ts
[Feat] Port Nuxt config to TypeScript
Nothing wrong here, but I like to have config files written in
*.ts
, both for consistency and tooling support. For example, to have intellisense in editors such asvscode
.Note that if
@typescript-eslint/no-unused-vars
is switched off, for this to work without linting errors the baseeslint
ruleno-unused-vars
must be switched off as well. This is recommended in the official docs, too.Edits
*.ts
file linting inlint
script withinpackage.json
pages/index.vue
andcomponents/Logo.vue
examplesThe text was updated successfully, but these errors were encountered: