Skip to content

Instantly share code, notes, and snippets.

@dimfeld
Last active June 13, 2018 21:49
Show Gist options
  • Save dimfeld/8acaa89e17de3028cb69d6c75ae39bb3 to your computer and use it in GitHub Desktop.
Save dimfeld/8acaa89e17de3028cb69d6c75ae39bb3 to your computer and use it in GitHub Desktop.
Typescript compiler crash on redundant export
import { abc } from './redundant_export';
abc(1, 2, 3);
// Removing either this `export` keyword or the `module.exports` assignment below makes the error disappear.
export function abc(a, b, c) {
return 5;
}
module.exports = {
abc,
};
{
"compilerOptions": {
"outDir": "./dist",
"target": "es2017",
"sourceMap": true,
"module": "commonjs",
"alwaysStrict": true,
"allowJs": true
},
"include": [
"*.js"
]
}
@dimfeld
Copy link
Author

dimfeld commented Jun 13, 2018

Just download the files and run tsc to see the crash. I first saw this in 2.9.1 and it's still present in 2.9.2 and next as of this writing.

> tsc
/usr/local/lib/node_modules/typescript/lib/tsc.js:63860
                throw e;
                ^

TypeError: Cannot read property 'kind' of undefined
    at getRootDeclaration (/usr/local/lib/node_modules/typescript/lib/tsc.js:8470:21)
    at Object.isCatchClauseVariableDeclarationOrBindingElement (/usr/local/lib/node_modules/typescript/lib/tsc.js:6763:20)
    at getTypeOfVariableOrParameterOrProperty (/usr/local/lib/node_modules/typescript/lib/tsc.js:25286:24)
    at getTypeOfSymbol (/usr/local/lib/node_modules/typescript/lib/tsc.js:25503:24)
    at getTypeOfAlias (/usr/local/lib/node_modules/typescript/lib/tsc.js:25458:23)
    at getTypeOfSymbol (/usr/local/lib/node_modules/typescript/lib/tsc.js:25515:24)
    at checkIdentifier (/usr/local/lib/node_modules/typescript/lib/tsc.js:33024:49)
    at checkExpressionWorker (/usr/local/lib/node_modules/typescript/lib/tsc.js:37653:28)
    at checkExpression (/usr/local/lib/node_modules/typescript/lib/tsc.js:37629:42)
    at checkNonNullExpression (/usr/local/lib/node_modules/typescript/lib/tsc.js:34916:37)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment