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.

See original GitHub issue

OS: Windows 10 64 Environment: node v10.14.2, ts-node v8.3.0, typescript v3.6.2

I receive this error only while running ts-node as the loader, but not while compiling with typescript directly. I’ve attached the contents of my project’s root\api dir, C:\www\node-framework\api for inspection. The only two files currently being touched by typescript should be C:\www\node-framework\api\src\framework.ts and C:\www\node-framework\api\src\app.ts

Full error:

$ node_modules/.bin/ts-node --require ts-node/register ./src/framework.ts

C:\www\node-framework\api\node_modules\ts-node\src\index.ts:245
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
src/framework.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) {
      ~~~~~~~~~~~~~~~
src/framework.ts:2:67 - error TS7006: Parameter 'mod' implicitly has an 'any' type.

2 var __importDefault = (this && this.__importDefault) || function (mod) {
                                                                    ~~~

    at createTSError (C:\www\node-framework\api\node_modules\ts-node\src\index.ts:245:12)
    at reportTSError (C:\www\node-framework\api\node_modules\ts-node\src\index.ts:249:19)
    at getOutput (C:\www\node-framework\api\node_modules\ts-node\src\index.ts:362:34)
    at Object.compile (C:\www\node-framework\api\node_modules\ts-node\src\index.ts:395:32)
    at Module.m._compile (C:\www\node-framework\api\node_modules\ts-node\src\index.ts:473:43)
    at Module.m._compile (C:\www\node-framework\api\node_modules\ts-node\src\index.ts:473:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at require.extensions.(anonymous function) (C:\www\node-framework\api\node_modules\ts-node\src\index.ts:476:12)
    at Object.require.extensions.(anonymous function) [as .ts] (C:\www\node-framework\api\node_modules\ts-node\src\index.ts:476:12)
[www_node-framework_api.zip](https://github.com/TypeStrong/ts-node/files/3588384/www_node-framework_api.zip)

    at Module.load (internal/modules/cjs/loader.js:599:32)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
blakeembreycommented, Sep 10, 2019

It looks like you’ve registered ts-node twice, so it’s compiling your TypeScript then again with the output from TypeScript.

6reactions
blakeembreycommented, Sep 10, 2019

It actually says so in your CLI: ts-node --require ts-node/register - use one or the other, not both at the same time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'items' implicitly has type 'any' because it does not have a type ...
'items' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer....
Read more >
How to fix typescript error error TS7022 - Stef Van Looveren
error TS7022 : 'path' implicitly has type 'any' because it does not have a type annotation and i s referenced directly or indirectly...
Read more >
Implicitly has return type 'any' because it does not have a ...
Implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly.
Read more >
webdriverio/webdriverio - Gitter
I've just migrated to webdriverio v.7 and found that I have errors with ... implicitly has type 'any' because it does not have...
Read more >
Problem with components that call each other - #2 by PeppeL-G
... implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer....
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