refactor(compiler-cli): remove usage of `ts.updateIdentifier` (#38076)
With Typescript 4, `ts.updateIdentifier` is no longer available. Calling `ts.updateIdentifier` used to return the same node when `typeArguments` was `undefined` because `node.typeArguments` was also `undefined`. Relevant TS code: ```js function updateIdentifier(node, typeArguments) { return node.typeArguments !== typeArguments ? updateNode(createIdentifier(ts.idText(node), typeArguments), node) : node; } ``` PR Close #38076
This commit is contained in:
parent
0fc44e0436
commit
281b647f15
|
@ -28,7 +28,7 @@ export function generateSetClassMetadataCall(
|
||||||
if (!reflection.isClass(clazz)) {
|
if (!reflection.isClass(clazz)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const id = ts.updateIdentifier(reflection.getAdjacentNameOfClass(clazz));
|
const id = reflection.getAdjacentNameOfClass(clazz);
|
||||||
|
|
||||||
// Reflect over the class decorators. If none are present, or those that are aren't from
|
// Reflect over the class decorators. If none are present, or those that are aren't from
|
||||||
// Angular, then return null. Otherwise, turn them into metadata.
|
// Angular, then return null. Otherwise, turn them into metadata.
|
||||||
|
|
|
@ -69,7 +69,7 @@ runInEachFileSystem(() => {
|
||||||
module: ts.ModuleKind.CommonJS,
|
module: ts.ModuleKind.CommonJS,
|
||||||
});
|
});
|
||||||
const fooClause = getDeclaration(program, _('/test.ts'), 'Foo', ts.isImportClause);
|
const fooClause = getDeclaration(program, _('/test.ts'), 'Foo', ts.isImportClause);
|
||||||
const fooId = ts.updateIdentifier(fooClause.name!);
|
const fooId = fooClause.name!;
|
||||||
const fooDecl = fooClause.parent;
|
const fooDecl = fooClause.parent;
|
||||||
|
|
||||||
const tracker = new DefaultImportTracker();
|
const tracker = new DefaultImportTracker();
|
||||||
|
|
|
@ -59,9 +59,7 @@ export function typeToValue(
|
||||||
|
|
||||||
return {
|
return {
|
||||||
kind: TypeValueReferenceKind.LOCAL,
|
kind: TypeValueReferenceKind.LOCAL,
|
||||||
// Copying the name here ensures the generated references will be correctly transformed
|
expression: firstDecl.name,
|
||||||
// along with the import.
|
|
||||||
expression: ts.updateIdentifier(firstDecl.name),
|
|
||||||
defaultImportStatement: firstDecl.parent,
|
defaultImportStatement: firstDecl.parent,
|
||||||
};
|
};
|
||||||
} else if (ts.isImportSpecifier(firstDecl)) {
|
} else if (ts.isImportSpecifier(firstDecl)) {
|
||||||
|
|
|
@ -110,10 +110,6 @@ function flipIvySwitchesInVariableStatement(
|
||||||
stmt.getSourceFile().fileName} for the Ivy switch.`);
|
stmt.getSourceFile().fileName} for the Ivy switch.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the identifier with updateIdentifier(). This copies the internal information which
|
|
||||||
// allows TS to write a correct reference to the identifier.
|
|
||||||
newIdentifier = ts.updateIdentifier(newIdentifier);
|
|
||||||
|
|
||||||
newDeclarations[i] = ts.updateVariableDeclaration(
|
newDeclarations[i] = ts.updateVariableDeclaration(
|
||||||
/* node */ decl,
|
/* node */ decl,
|
||||||
/* name */ decl.name,
|
/* name */ decl.name,
|
||||||
|
|
Loading…
Reference in New Issue