From 51c76ac35128adba8a760fc08092e0035a1b5cd5 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 8 May 2017 18:17:17 -0700 Subject: [PATCH] fix malformed nodes --- src/compiler/checker.ts | 6 +++--- src/compiler/factory.ts | 4 ++++ src/compiler/utilities.ts | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 658bad82f83..9ac1dc2d615 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2752,7 +2752,7 @@ namespace ts { function indexInfoToIndexSignatureDeclarationHelper(indexInfo: IndexInfo, kind: IndexKind, context: NodeBuilderContext): IndexSignatureDeclaration { const indexerTypeNode = createKeywordTypeNode(kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); - const name = getNameFromIndexInfo(indexInfo); + const name = getNameFromIndexInfo(indexInfo) || "x"; const indexingParameter = createParameter( /*decorators*/ undefined, @@ -2830,8 +2830,8 @@ namespace ts { initializer = parameterDeclaration.initializer; } const parameterNode = createParameter( - parameterDeclaration.decorators, - parameterDeclaration.modifiers, + /*decorators*/ undefined, + cloneNodeArray(parameterDeclaration.modifiers), (parameterDeclaration ? isRestParameter(parameterDeclaration) : isTransientSymbol(parameterSymbol) && parameterSymbol.isRestParameter) ? createToken(SyntaxKind.DotDotDotToken) : undefined, diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 172710f39aa..45b09892bb0 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -89,6 +89,10 @@ namespace ts { return nodeIsSynthesized(clone) ? clone : getSynthesizedClone(clone); } + export function cloneNodeArray(nodeArray: NodeArray) { + return nodeArray && nodeArray.map(getDeepSynthesizedClone); + } + // Literals export function createLiteral(value: string): StringLiteral; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index cd63ebfb690..baa83697fba 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -466,7 +466,7 @@ namespace ts { return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } - export function getNameFromIndexInfo(info: IndexInfo) { + export function getNameFromIndexInfo(info: IndexInfo): string | undefined { return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined; }