question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A typescript compile error occurs when nuxt.config.ts has changed in development mode if noImplicitAny enabled.

See original GitHub issue

Version

v2.6.3

Reproduction link

https://github.com/SegaraRai/nuxt-ts-issue-multiregister

Steps to reproduce

  1. clone the repository
  2. npm install
  3. npm run dev
  4. 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.

<div align="right">This bug report is available on Nuxt community (#c9133)</div>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
kevinmarreccommented, May 11, 2019

@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.

1reaction
kevinmarreccommented, May 11, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found