type predicate support

This commit is contained in:
Arthur Ozga
2017-03-27 11:53:44 -07:00
parent a39bb0aaaa
commit 7340c4ca1e
9 changed files with 93 additions and 68 deletions

View File

@@ -65,10 +65,10 @@ namespace ts.codefix {
stringTypeNode,
/*initializer*/ undefined);
const indexSignature = createIndexSignatureDeclaration(
[indexingParameter],
typeNode,
/*decorators*/undefined,
/*modifiers*/ undefined);
/*modifiers*/ undefined,
[indexingParameter],
typeNode);
const indexSignatureChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context);
indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { suffix: context.newLineCharacter });

View File

@@ -230,12 +230,4 @@ namespace ts.codefix {
}
return undefined;
}
function stripComments(node: Node): Node {
if (node === undefined) {
return node;
}
const strippedChildren = visitEachChild(node, stripComments, nullTransformationContext);
return strippedChildren === node ? getSynthesizedClone(strippedChildren) : strippedChildren;
}
}

View File

@@ -528,6 +528,26 @@ namespace ts.textChanges {
return skipTrivia(s, 0) === s.length;
}
const nullTransformationContext: TransformationContext = {
enableEmitNotification: noop,
enableSubstitution: noop,
endLexicalEnvironment: () => undefined,
getCompilerOptions: notImplemented,
getEmitHost: notImplemented,
getEmitResolver: notImplemented,
hoistFunctionDeclaration: noop,
hoistVariableDeclaration: noop,
isEmitNotificationEnabled: notImplemented,
isSubstitutionEnabled: notImplemented,
onEmitNode: noop,
onSubstituteNode: notImplemented,
readEmitHelpers: notImplemented,
requestEmitHelper: noop,
resumeLexicalEnvironment: noop,
startLexicalEnvironment: noop,
suspendLexicalEnvironment: noop
};
function assignPositionsToNode(node: Node): Node {
const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode);
// create proxy node for non synthesized nodes