Skip to content

TSC Watch crashes when class is exported as module.exports.default in JS file - cannot read property 'kind' of undefined #41101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
myfatemi04 opened this issue Oct 14, 2020 · 2 comments
Assignees
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Duplicate An existing issue was already created

Comments

@myfatemi04
Copy link

I get this error:

[12:18:51 PM] Starting compilation in watch mode...

C:\Users\legoc\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:84774
                throw e;
                ^

TypeError: Cannot read property 'kind' of undefined
    at Object.isEntityNameExpression (C:\Users\legoc\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:13169:21)
    at serializeMaybeAliasAssignment (C:\Users\legoc\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:39495:42)
    at serializeSymbolWorker (C:\Users\legoc\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:39161:49)
    at serializeSymbol (C:\Users\legoc\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:39126:38)
    at C:\Users\legoc\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:39107:25
    at Map.forEach (<anonymous>)
    at visitSymbolTable (C:\Users\legoc\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:39106:33)
    at serializeAsNamespaceDeclaration (C:\Users\legoc\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:39370:25)
    at serializeAsFunctionNamespaceMerge (C:\Users\legoc\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:39348:25)
    at serializeMaybeAliasAssignment (C:\Users\legoc\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:39525:29)

This happens when I create a file called "index.js" and try to compile it with tsc -w.

Here is my tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "outDir": "dist",
    "sourceMap": true,
    "strict": true,
    "target": "es2017",
    "noImplicitAny": false,
    "allowJs": true
  },
  "compileOnSave": true,
  "include": [ "src" ]
}

TSC breaks and doesn't offer a helpful error message.
The following is the code that can be used to reproduce this exact error.
I spent over an hour to isolate the error; it didn't mention which file produced the error or etc.
Strangely enough, running just tsc by itself compiles the code successfully.

class TestClass {}

module.exports = {
    default: TestClass
}
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Oct 14, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.2.0 milestone Oct 14, 2020
@RyanCavanaugh RyanCavanaugh added the Domain: Declaration Emit The issue relates to the emission of d.ts files label Oct 14, 2020
@a-tarasyuk
Copy link
Contributor

It seems duplicate of #41101.

@weswigham
Copy link
Member

If you mean dupe of #40554 then, probably. This is definitely fixed in master, though.

@weswigham weswigham added the Duplicate An existing issue was already created label Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants