fix malformed nodes

This commit is contained in:
Arthur Ozga 2017-05-08 18:17:17 -07:00
parent d9b68e9213
commit 51c76ac351
3 changed files with 8 additions and 4 deletions

View File

@ -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,

View File

@ -89,6 +89,10 @@ namespace ts {
return nodeIsSynthesized(clone) ? clone : getSynthesizedClone(clone);
}
export function cloneNodeArray<T extends Node>(nodeArray: NodeArray<T>) {
return nodeArray && nodeArray.map(getDeepSynthesizedClone);
}
// Literals
export function createLiteral(value: string): StringLiteral;

View File

@ -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;
}