A typescript compile error occurs when nuxt.config.ts has changed in development mode if noImplicitAny enabled.
See original GitHub issueVersion
Reproduction link
https://github.com/SegaraRai/nuxt-ts-issue-multiregister
Steps to reproduce
- clone the repository
npm install
npm run dev
- make some changes to nuxt.config.ts after first compilation finished
- this will have nuxt rebuild whole app
What is expected ?
work with no error
What is actually happening?
A typescript compile error occurs.
ERROR ⨯ Unable to compile TypeScript: 12:43:28
nuxt.config.ts:2:5 - error TS7022: '__importDefault' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
2 var __importDefault = (this && this.__importDefault) || function (mod) {
~~~~~~~~~~~~~~~
nuxt.config.ts:2:67 - error TS7006: Parameter 'mod' implicitly has an 'any' type.
2 var __importDefault = (this && this.__importDefault) || function (mod) {
~~~
nuxt.config.ts:5:5 - error TS7022: '__importStar' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
…
Additional comments?
The cause of this issue is that registerTsNode is called more than once.
Because of this, ts-node tries compiling already transpiled .ts code and noImplicitAny error occurs.
registerTsNode is called everytime in _startDev via detectTypeScript and getNuxtConfig.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Setup - Nuxt TypeScript
Nuxt TypeScript Support mainly comes through a Nuxt module, @nuxt/typescript-build, and its types @nuxt/types. Here are the guidelines to install & configure ......
Read more >How can I disable all typescript type checking? - Stack Overflow
Only the second solution will work. TSLint is not the typescript compiler, and an empty tsconfig will just use the default settings. – ......
Read more >TypeScript errors and how to fix them
ts ' cannot be compiled under '–isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export...
Read more >TypeScript with Composition API - Vue.js
If not using <script setup> , it is necessary to use defineComponent() to enable props type inference. The type of the props object...
Read more >How to move your project to TypeScript - at your own pace
Even if an error like this is thrown, your code might still run. ... Configuring the TypeScript compiler for JavaScript.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@SegaraRai I fixed the double registration and tested it on your repository, it fixes your issue 😃 Fix can be found here : https://github.com/nuxt/nuxt.js/pull/5699 and will be shipped for next release very soon.
@SegaraRai Alright, we had a guard to prevent double subscribtion but with some last refactors it seems there isn’t one anymore.
I’m gonna look if we can prevent it again and hopefully it would fix your problem.