mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-26 00:36:29 -05:00
Don't copy trivia when implementing an interface (#23343)
* Don't copy trivia when implementing an interface * Use an `includeTrivia` flag instead of a separate function
This commit is contained in:
@@ -25,8 +25,7 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
const declaration = declarations[0];
|
||||
// Clone name to remove leading trivia.
|
||||
const name = getSynthesizedDeepClone(getNameOfDeclaration(declaration)) as PropertyName;
|
||||
const name = getSynthesizedDeepClone(getNameOfDeclaration(declaration), /*includeTrivia*/ false) as PropertyName;
|
||||
const visibilityModifier = createVisibilityModifier(getModifierFlags(declaration));
|
||||
const modifiers = visibilityModifier ? createNodeArray([visibilityModifier]) : undefined;
|
||||
const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
||||
@@ -69,7 +68,7 @@ namespace ts.codefix {
|
||||
|
||||
for (const signature of signatures) {
|
||||
// Need to ensure nodes are fresh each time so they can have different positions.
|
||||
outputMethod(signature, getSynthesizedDeepClones(modifiers), getSynthesizedDeepClone(name));
|
||||
outputMethod(signature, getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), getSynthesizedDeepClone(name, /*includeTrivia*/ false));
|
||||
}
|
||||
|
||||
if (declarations.length > signatures.length) {
|
||||
@@ -103,10 +102,6 @@ namespace ts.codefix {
|
||||
return signatureDeclaration;
|
||||
}
|
||||
|
||||
function getSynthesizedDeepClones<T extends Node>(nodes: NodeArray<T> | undefined): NodeArray<T> | undefined {
|
||||
return nodes && createNodeArray(nodes.map(getSynthesizedDeepClone));
|
||||
}
|
||||
|
||||
export function createMethodFromCallExpression(
|
||||
{ typeArguments, arguments: args }: CallExpression,
|
||||
methodName: string,
|
||||
|
||||
Reference in New Issue
Block a user