refactor(compiler-cli): remove unused return type transform (#41996)
With the removal of the `ModuleWithProviders` transform in the parent commit, the underlying dts transform can also be removed as it is not used elsewhere. PR Close #41996
This commit is contained in:
parent
ce8720910d
commit
69e57827e2
|
@ -9,6 +9,6 @@
|
|||
export * from './src/api';
|
||||
export {aliasTransformFactory} from './src/alias';
|
||||
export {ClassRecord, TraitCompiler} from './src/compilation';
|
||||
export {declarationTransformFactory, DtsTransformRegistry, IvyDeclarationDtsTransform, ReturnTypeTransform} from './src/declaration';
|
||||
export {declarationTransformFactory, DtsTransformRegistry, IvyDeclarationDtsTransform} from './src/declaration';
|
||||
export {AnalyzedTrait, PendingTrait, ResolvedTrait, SkippedTrait, Trait, TraitState} from './src/trait';
|
||||
export {ivyTransformFactory} from './src/transform';
|
||||
|
|
|
@ -22,7 +22,6 @@ import {addImports} from './utils';
|
|||
*/
|
||||
export class DtsTransformRegistry {
|
||||
private ivyDeclarationTransforms = new Map<ts.SourceFile, IvyDeclarationDtsTransform>();
|
||||
private returnTypeTransforms = new Map<ts.SourceFile, ReturnTypeTransform>();
|
||||
|
||||
getIvyDeclarationTransform(sf: ts.SourceFile): IvyDeclarationDtsTransform {
|
||||
if (!this.ivyDeclarationTransforms.has(sf)) {
|
||||
|
@ -31,13 +30,6 @@ export class DtsTransformRegistry {
|
|||
return this.ivyDeclarationTransforms.get(sf)!;
|
||||
}
|
||||
|
||||
getReturnTypeTransform(sf: ts.SourceFile): ReturnTypeTransform {
|
||||
if (!this.returnTypeTransforms.has(sf)) {
|
||||
this.returnTypeTransforms.set(sf, new ReturnTypeTransform());
|
||||
}
|
||||
return this.returnTypeTransforms.get(sf)!;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dts transforms to be applied for the given source file, or `null` if no transform is
|
||||
* necessary.
|
||||
|
@ -57,10 +49,6 @@ export class DtsTransformRegistry {
|
|||
transforms = [];
|
||||
transforms.push(this.ivyDeclarationTransforms.get(originalSf)!);
|
||||
}
|
||||
if (this.returnTypeTransforms.has(originalSf)) {
|
||||
transforms = transforms || [];
|
||||
transforms.push(this.returnTypeTransforms.get(originalSf)!);
|
||||
}
|
||||
return transforms;
|
||||
}
|
||||
}
|
||||
|
@ -230,50 +218,3 @@ function markForEmitAsSingleLine(node: ts.Node) {
|
|||
ts.setEmitFlags(node, ts.EmitFlags.SingleLine);
|
||||
ts.forEachChild(node, markForEmitAsSingleLine);
|
||||
}
|
||||
|
||||
export class ReturnTypeTransform implements DtsTransform {
|
||||
private typeReplacements = new Map<ts.Declaration, Type>();
|
||||
|
||||
addTypeReplacement(declaration: ts.Declaration, type: Type): void {
|
||||
this.typeReplacements.set(declaration, type);
|
||||
}
|
||||
|
||||
transformClassElement(element: ts.ClassElement, imports: ImportManager): ts.ClassElement {
|
||||
if (ts.isMethodDeclaration(element)) {
|
||||
const original = ts.getOriginalNode(element, ts.isMethodDeclaration);
|
||||
if (!this.typeReplacements.has(original)) {
|
||||
return element;
|
||||
}
|
||||
const returnType = this.typeReplacements.get(original)!;
|
||||
const tsReturnType = translateType(returnType, imports);
|
||||
|
||||
return ts.updateMethod(
|
||||
element, element.decorators, element.modifiers, element.asteriskToken, element.name,
|
||||
element.questionToken, element.typeParameters, element.parameters, tsReturnType,
|
||||
element.body);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
transformFunctionDeclaration(element: ts.FunctionDeclaration, imports: ImportManager):
|
||||
ts.FunctionDeclaration {
|
||||
const original = ts.getOriginalNode(element) as ts.FunctionDeclaration;
|
||||
if (!this.typeReplacements.has(original)) {
|
||||
return element;
|
||||
}
|
||||
const returnType = this.typeReplacements.get(original)!;
|
||||
const tsReturnType = translateType(returnType, imports);
|
||||
|
||||
return ts.updateFunctionDeclaration(
|
||||
/* node */ element,
|
||||
/* decorators */ element.decorators,
|
||||
/* modifiers */ element.modifiers,
|
||||
/* asteriskToken */ element.asteriskToken,
|
||||
/* name */ element.name,
|
||||
/* typeParameters */ element.typeParameters,
|
||||
/* parameters */ element.parameters,
|
||||
/* type */ tsReturnType,
|
||||
/* body */ element.body);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue