Repository navigation
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts filesDomain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specifically
Milestone
Description
TypeScript Version: "3.7.0-dev.20191001"
Search Terms:
Code
// file.jsx
import PropTypes from 'prop-types';
import React from 'react';
const propTypes = {
bar: PropTypes.bool,
};
const defaultProps = {
bar: false,
};
function Foo({ bar }) {
return <div>{bar}</div>;
}
Foo.propTypes = propTypes;
Foo.defaultProps = defaultProps;
export default Foo;compiler options
{
"compilerOptions": {
"target": "es2015",
"module": "commonjs",
"moduleResolution": "node",
"jsx": "react",
"lib": ["dom", "es2017", "esnext.asynciterable"],
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"composite": true,
"esModuleInterop": true,
"downlevelIteration": true,
"strict": true,
"noErrorTruncation": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"importHelpers": true
},
"exclude": ["node_modules", "projects/*/node_modules", "projects/*/lib", "projects/*/build"]
}
{
"extends": "./tsconfig.settings.json",
"compilerOptions": {
"allowJs": true
},
"files": [
"/path/to/file.jsx"
]
}
Expected behavior:
No error
Actual behavior:
Compiler crashes with:
/work/node_modules/typescript/lib/tsc.js:78403
throw e;
^
TypeError: Cannot read property 'declarations' of undefined
at getSpecifierForModuleSymbol (/work/node_modules/typescript/lib/tsc.js:30502:61)
at serializeAsAlias (/work/node_modules/typescript/lib/tsc.js:31191:171)
at serializeSymbolWorker (/work/node_modules/typescript/lib/tsc.js:30971:25)
at serializeSymbol (/work/node_modules/typescript/lib/tsc.js:30923:38)
at /work/node_modules/typescript/lib/tsc.js:30908:29
at Map.forEach (<anonymous>)
at visitSymbolTable (/work/node_modules/typescript/lib/tsc.js:30907:42)
at serializeAsNamespaceDeclaration (/work/node_modules/typescript/lib/tsc.js:31132:25)
at serializeModule (/work/node_modules/typescript/lib/tsc.js:31051:25)
at serializeSymbolWorker (/work/node_modules/typescript/lib/tsc.js:30965:25)
Reacted by Brie, Deividas Bakanas, Sergii Rudenko, Pleun Vanderbauwhede and Bnaya Peretz
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts filesDomain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specifically
Activity
weswigham commentedon Oct 3, 2019
Excellent and succinct repro, thanks ❤️ I'll work on a fix tomorrow - the issue seems to be that an assumption made that a
import def from "foo"alias target always has a parent symbol isn't quite true whenesModuleInteropis on (as the target may end up being the module itself!)ajayvikas commentedon Oct 18, 2019
I just tried with the latest build, I am still getting this error.
weswigham commentedon Oct 18, 2019
"latest build" being @next? Or the beta? The fix is still only in @next and hasn't shipped in a tagged release yet.
ajayvikas commentedon Oct 19, 2019
Sorry I was not very specific. I took the @next. Precise build number is 3.7.0-dev.20191018.
noahseger commentedon Oct 21, 2019
Same as ppN2, but downgrading to
3.7.0-dev.20191017let me compile without this error.capaj commentedon Nov 20, 2020
I got this today when I updated 4.0.1 to 4.1.2 on a big project(has
esModuleInteropenabled):I should probably open this as a new ticket right Wesley Wigham (@weswigham) ?
weswigham commentedon Nov 20, 2020
Yeah, that stack trace is entirely different.