Skip to content

"TypeError: Cannot read property 'kind' of undefined" when "incremental" is enabled #40819

@salemhilal

Description

@salemhilal

I run into an exception that only occurs when incremental is enabled. When it's disabled, typechecking occurs as expected and completes in around 40 seconds. When it's enabled, typechecking takes several minutes and produces the error below:

╰─ yarn typecheck
yarn run v1.22.4
$ env NODE_OPTIONS="--max-old-space_size=16000 --trace-warnings" yarnpkg tsc --project tsconfig.json
$ /home/shilal/development/Etsyweb/node_modules/.bin/tsc --project tsconfig.json
/home/shilal/development/Etsyweb/node_modules/typescript/lib/tsc.js:84774
                throw e;
                ^

TypeError: Cannot read property 'kind' of undefined
    at Object.isEntityNameExpression (/home/shilal/development/Etsyweb/node_modules/typescript/lib/tsc.js:13169:21)
    at serializeMaybeAliasAssignment (/home/shilal/development/Etsyweb/node_modules/typescript/lib/tsc.js:39495:42)
    at serializeSymbolWorker (/home/shilal/development/Etsyweb/node_modules/typescript/lib/tsc.js:39161:49)
    at serializeSymbol (/home/shilal/development/Etsyweb/node_modules/typescript/lib/tsc.js:39126:38)
    at /home/shilal/development/Etsyweb/node_modules/typescript/lib/tsc.js:39107:25
    at Map.forEach (<anonymous>)
    at visitSymbolTable (/home/shilal/development/Etsyweb/node_modules/typescript/lib/tsc.js:39106:33)
    at serializeAsNamespaceDeclaration (/home/shilal/development/Etsyweb/node_modules/typescript/lib/tsc.js:39370:25)
    at serializeAsFunctionNamespaceMerge (/home/shilal/development/Etsyweb/node_modules/typescript/lib/tsc.js:39348:25)
    at serializeMaybeAliasAssignment (/home/shilal/development/Etsyweb/node_modules/typescript/lib/tsc.js:39525:29)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Some things of note:

  • I'm working in a monorep with around 13k JS files.
  • There are currently only 2 TypeScript files.
  • noEmit is enabled and checkJs is disabled.

TypeScript Version: 4.0.3

Search Terms:
Cannot read property 'kind' of undefined

Code
There's quite a bit of code, and because it takes so long to run the failure case, it's been hard to narrow down the problem. I'd love any advice here. My TSConfig looks like this, if it's of any help:

{
  "compilerOptions": {
    "jsx": "react",
    "allowJs": true,
    "checkJs": false,
    "noEmit": true,
    "incremental": true,
    "extendedDiagnostics": true,
    "skipLibCheck": true,
    "noFallthroughCasesInSwitch": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "esModuleInterop": true,
    "noUnusedLocals": true,
    "strictNullChecks": true,
    "noImplicitAny": true,
    "declaration": false,
    "target": "ES2019",
    "module": "ES2015",
    "moduleResolution": "node",
    "baseUrl": ".",

    "paths": {
      "*": ["*", "./htdocs/assets/js/*"],
      "jquery": ["node_modules/jquery-2"],
      "template!*": ["./templates/*", "./templates/*.mustache"]
    }
  },

  "include": [
    "htdocs/assets/js/@types/",
    "htdocs/assets/js"
  ],

  "exclude": [
    "node_modules"
  ]
}

Expected behavior:
The first run of the type checker should complete in a reasonable amount of time with incremental enabled, and subsequent runs should be faster.

Actual behavior:
The exception above is thrown.

Playground Link:
N/A

Related Issues:
This issue might be related, but I think it's more likely that they both just have similar error messages.
#40522

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions