This commit is contained in:
Ryan Cavanaugh
2017-12-06 15:58:50 -08:00
parent 5e5b7706e5
commit 6e74f7ee11
2 changed files with 14 additions and 0 deletions

View File

@@ -148,6 +148,11 @@ namespace ts.codefix {
containingFunction.parameters.map(p => isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, sourceFile, program, cancellationToken) : undefined);
if (!types) return undefined;
// We didn't actually find a set of type inference positions matching each parameter position
if (containingFunction.parameters.length !== types.length) {
return undefined;
}
const textChanges = arrayFrom(mapDefinedIterator(zipToIterator(containingFunction.parameters, types), ([parameter, type]) =>
type && !parameter.type && !parameter.initializer ? makeChange(containingFunction, parameter.end, type, program) : undefined));
return textChanges.length ? { declaration: parameterDeclaration, textChanges } : undefined;

View File

@@ -0,0 +1,9 @@
/// <reference path='fourslash.ts' />
// @noImplicitAny: true
//// function f(/*1*/x) {
//// }
//// f(
verify.not.codeFixAvailable([]);