-
Notifications
You must be signed in to change notification settings - Fork 12.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot read property 'valueDeclaration' of undefined #46223
Comments
There's a lot of files in this repo; would you be able to help us narrow down the issue more quickly by providing a minimal repro with just 1-2 files? |
Does the issue reproduce with |
@DanielRosenwasser I have tried to make this issue reproducible with fewer files, however, I can only point out that this problem is related to the following lines: type Constructor<I extends Object> = InstanceInterface<I>
/**
* Huan(202110): TypeError: Cannot read property 'valueDeclaration' of undefined #58
* https://github.com/huan/clone-class/issues/58
*/
// type Constructor<I extends Object, C = any> = ClassInterface<C> & InstanceInterface<I> If I uncomment the bottom line, then this issue will appear. However, if I only get this file out of the whole repo, then this issue will disappear. It seems it's related to this line, plus some other unknown files. @andrewbranch Yes, this issue still reproduces with $ npx tsc --version
Version 4.5.0-dev.20211006
$ npx tsc
/home/huan/git/huan/clone-class/node_modules/typescript/lib/tsc.js:94207
throw e;
^
TypeError: Cannot read property 'valueDeclaration' of undefined
at checkIndexConstraints (/home/huan/git/huan/clone-class/node_modules/typescript/lib/tsc.js:67995:47)
at checkClassLikeDeclaration (/home/huan/git/huan/clone-class/node_modules/typescript/lib/tsc.js:68287:17)
at checkClassDeclaration (/home/huan/git/huan/clone-class/node_modules/typescript/lib/tsc.js:68183:13)
at checkSourceElementWorker (/home/huan/git/huan/clone-class/node_modules/typescript/lib/tsc.js:69606:28)
at checkSourceElement (/home/huan/git/huan/clone-class/node_modules/typescript/lib/tsc.js:69444:17)
at Object.forEach (/home/huan/git/huan/clone-class/node_modules/typescript/lib/tsc.js:132:30)
at checkBlock (/home/huan/git/huan/clone-class/node_modules/typescript/lib/tsc.js:66768:20)
at checkSourceElementWorker (/home/huan/git/huan/clone-class/node_modules/typescript/lib/tsc.js:69569:28)
at checkSourceElement (/home/huan/git/huan/clone-class/node_modules/typescript/lib/tsc.js:69444:17)
at checkFunctionOrMethodDeclaration (/home/huan/git/huan/clone-class/node_modules/typescript/lib/tsc.js:66466:13) |
Here's the repro // @noEmit: true
export type ClassInterface<C> = {
[key in keyof C]: C[key];
}
type InstanceInterface<I> = {
new(...args: any[]): I
prototype: I
}
type Constructor<I extends Object, C = any> = ClassInterface<C> & InstanceInterface<I>
function cloneClass<T extends Constructor<{}>>(OriginalClass: T): T {
class AnotherOriginalClass extends OriginalClass {
constructor(...args: any[]) {
super(...args)
}
}
return AnotherOriginalClass
} |
Dear @DanielRosenwasser , it's so brilliant to get the reproducible code! Before fixing it, could we have any workaround for this code, so that my repo can work as expected under a specific version of TypeScript(4.4, or next, or dev version are all acceptable)? Thank you very much and appreciate your help. |
Reproduce steps
Related Issue
The text was updated successfully, but these errors were encountered: