fix(core): undecorated-classes-with-decorated-fields migration should avoid error if base class has no value declaration (#36543)
The undecorated-classes-with-decorated-fields migration relies on the type checker to resolve base classes of individual classes. It could happen that resolved base classes have no value declaration. e.g. if they are declared through an interface in the default types. Currently the migration will throw in such situations because it assumes that `ts.Symbol#valueDeclaration` is always present. This is not the case, but we don't get good type-checking here due to a bug in the TypeScript types. See: https://github.com/microsoft/TypeScript/issues/24706. Fixes #36522. PR Close #36543
This commit is contained in:

committed by
atscott

parent
6ab43d7335
commit
ca677481a2
@ -20,7 +20,9 @@ export function findBaseClassDeclarations(node: ts.ClassDeclaration, typeChecker
|
||||
break;
|
||||
}
|
||||
const symbol = typeChecker.getTypeAtLocation(baseTypes[0]).getSymbol();
|
||||
if (!symbol || !ts.isClassDeclaration(symbol.valueDeclaration)) {
|
||||
// Note: `ts.Symbol#valueDeclaration` can be undefined. TypeScript has an incorrect type
|
||||
// for this: https://github.com/microsoft/TypeScript/issues/24706.
|
||||
if (!symbol || !symbol.valueDeclaration || !ts.isClassDeclaration(symbol.valueDeclaration)) {
|
||||
break;
|
||||
}
|
||||
result.push({identifier: baseTypes[0], node: symbol.valueDeclaration});
|
||||
|
Reference in New Issue
Block a user