basic end-to-end building type nodes

This commit is contained in:
Arthur Ozga
2017-03-11 18:58:46 -08:00
parent fff531ca25
commit bf2acf1d2c
6 changed files with 159 additions and 62 deletions

View File

@@ -62,13 +62,12 @@ namespace ts.codefix {
, "name"
, /*questionToken*/ undefined
, stringTypeNode);
const indexSignature = createIndexSignature(indexingParameter, typeNode);
const indexSignature = createIndexSignatureDeclaration([indexingParameter], typeNode);
// const startPos = classDeclaration.members.pos;
const indexSignatureChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context);
indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { insertTrailingNewLine: true });
return [{
return [{
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]),
changes: propertyChangeTracker.getChanges()
},

View File

@@ -1386,6 +1386,6 @@ namespace ts {
}
export function getOpenBraceOfClassLike(declaration: ClassLikeDeclaration, sourceFile: SourceFile) {
return getTokenAtPosition(sourceFile, declaration.members.pos);
return getTokenAtPosition(sourceFile, declaration.members.pos - 1);
}
}