mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
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:
@@ -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 }],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user