Closed
Description
TypeScript Version: 4.1.2
Search Terms: key union, useDefineForClassFields
Code
Given useDefineForClassFields is set to true
type M<MP extends { [k: string]: {} }> = {
[k in keyof MP & string]: any // if & string is ommited then it compiles ok
}
function F<D extends { [k: string]: {} }>(
_d: D
): {
new (): M<D>
} {
return null as any
}
class P extends F({ x: {} }) {}
Expected behavior:
It should compile without crashing
Actual behavior:
TypeError: Cannot read property 'length' of undefined
at Object.find (../../node_modules/typescript/lib/typescript.js:509:35)
at checkKindsOfPropertyMemberOverrides (../../node_modules/typescript/lib/typescript.js:75911:52)
at checkClassLikeDeclaration (../../node_modules/typescript/lib/typescript.js:75736:21)
at checkClassDeclaration (../../node_modules/typescript/lib/typescript.js:75662:13)
at checkSourceElementWorker (../../node_modules/typescript/lib/typescript.js:77032:28)
at checkSourceElement (../../node_modules/typescript/lib/typescript.js:76873:17)
at Object.forEach (../../node_modules/typescript/lib/typescript.js:382:30)
at checkSourceFileWorker (../../node_modules/typescript/lib/typescript.js:77217:20)
at checkSourceFile (../../node_modules/typescript/lib/typescript.js:77184:13)
at getDiagnosticsWorker (../../node_modules/typescript/lib/typescript.js:77273:17)
Playground Link:
See the crash in the browser console
Related Issues: