Closed
Description
TypeScript Version: 3.7.x-dev.20191011
Search Terms: "Cannot read property 'parent' of undefined"
Code (JavaScript)
/**
* @class
*/
function MyClass() {}
/**
* @returns {new () => MyClass}
*/
export function createSpecialMyClass() {
var f = function() {
return new MyClass();
};
f.prototype.a = "a";
return f;
}
tsconfig.json
:
{
"compilerOptions": {
"allowJs": true,
"declaration": true,
"rootDir": "src",
"outDir": "dist"
},
"include": ["src"]
}
Expected behavior:
Compiles and emits .js
+ .d.ts
.
Actual behavior:
Error:
TypeError: Cannot read property 'parent' of undefined
at getOuterTypeParameters (/Users/johng/dev/typescript-allowjs-bug/node_modules/typescript/lib/tsc.js:32718:29)
at getOuterTypeParametersOfClassOrInterface (/Users/johng/dev/typescript-allowjs-bug/node_modules/typescript/lib/tsc.js:32769:20)
at getDeclaredTypeOfClassOrInterface (/Users/johng/dev/typescript-allowjs-bug/node_modules/typescript/lib/tsc.js:33003:43)
at compareSignaturesRelated (/Users/johng/dev/typescript-allowjs-bug/node_modules/typescript/lib/tsc.js:37883:83)
at signatureRelatedTo (/Users/johng/dev/typescript-allowjs-bug/node_modules/typescript/lib/tsc.js:39492:24)
at signaturesRelatedTo (/Users/johng/dev/typescript-allowjs-bug/node_modules/typescript/lib/tsc.js:39455:30)
at structuredTypeRelatedTo (/Users/johng/dev/typescript-allowjs-bug/node_modules/typescript/lib/tsc.js:39034:43)
at recursiveTypeRelatedTo (/Users/johng/dev/typescript-allowjs-bug/node_modules/typescript/lib/tsc.js:38783:53)
at isRelatedTo (/Users/johng/dev/typescript-allowjs-bug/node_modules/typescript/lib/tsc.js:38405:38)
at checkTypeRelatedTo (/Users/johng/dev/typescript-allowjs-bug/node_modules/typescript/lib/tsc.js:38089:26)
Playground Link:
Unable to figure out how to create a playground link with declaration: true
.
Related Issues:
#33735 maybe? This one was blocking me previously.