Bundle fileName with CodeActionCommand (#19881)

* Bundle fileName with CodeActionCommand

* Update test

* Fix API tests

* Add new overloads in services

* Fix overload

* Update API baselines
This commit is contained in:
Andy
2017-11-17 14:16:38 -08:00
committed by GitHub
parent 0c0f4b81ae
commit e7adb1ce79
10 changed files with 46 additions and 20 deletions
@@ -11,12 +11,12 @@ namespace ts.codefix {
throw Debug.fail(); // These errors should only happen on the module name.
}
const action = tryGetCodeActionForInstallPackageTypes(context.host, token.text);
const action = tryGetCodeActionForInstallPackageTypes(context.host, sourceFile.fileName, token.text);
return action && [action];
},
});
export function tryGetCodeActionForInstallPackageTypes(host: LanguageServiceHost, moduleName: string): CodeAction | undefined {
export function tryGetCodeActionForInstallPackageTypes(host: LanguageServiceHost, fileName: string, moduleName: string): CodeAction | undefined {
const { packageName } = getPackageName(moduleName);
if (!host.isKnownTypesPackageName(packageName)) {
@@ -28,7 +28,7 @@ namespace ts.codefix {
return {
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Install_0), [typesPackageName]),
changes: [],
commands: [{ type: "install package", packageName: typesPackageName }],
commands: [{ type: "install package", file: fileName, packageName: typesPackageName }],
};
}
}