Skip to content

Cannot read property 'heritageClauses' of undefined #36273

Closed
@Fsss126

Description

@Fsss126

TypeScript Version: 3.7.5

Code

When I add

import 'whatwg-fetch';

in my project with Webpack and run a command to build it or start watching for changes it fails with error

TypeError: Cannot read property 'heritageClauses' of undefined
    at getClassExtendsHeritageElement (/Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:12354:53)
    at Object.getEffectiveBaseTypeNode (/Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:12342:24)
    at getBaseConstructorTypeOfClass (/Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:40022:35)
    at serializeAsClass (/Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:38029:42)
    at serializeSymbolWorker (/Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:37763:29)
    at serializeSymbol (/Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:37704:38)
    at /Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:37679:25
    at Map.forEach (<anonymous>)
    at visitSymbolTable (/Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:37678:33)
    at symbolTableToDeclarationStatements (/Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:37549:17)
    at /Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:36346:106
    at withContext (/Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:36367:37)
    at Object.symbolTableToDeclarationStatements (/Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:36346:28)
    at Object.getDeclarationStatementsForSourceFile (/Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:64426:60)
    at transformDeclarationsForJS (/Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:88037:35)
    at transformRoot (/Users/alex/WebstormProjects/rete-tracker/node_modules/typescript/lib/typescript.js:88114:57)

But it compiles just fine if add this line later when Webpack is already watching for changes in files.

whatwg-fetch has the following in its package.json:

"main": "./dist/fetch.umd.js",
"module": "./fetch.js",

The problem occurs when the module export picked by default, when I point to the script exported as main with

import 'whatwg-fetch/dist/fetch.umd';

everything works fine.

I have the following tsconfig:

{
  "compilerOptions": {
    "target": "es2018",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "outDir": "dist/core", 
    "noEmitOnError": true,
    "sourceMap": true,
    "baseUrl": "src",
    "strictNullChecks": true,
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "downlevelIteration": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "typeRoots": [
      "./node_modules/@types",
      "./src/declarations"
    ]
  },
  "include": [
    "src"
  ]
}

Related Issues: #10268

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