Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/services/codefixes/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,12 @@ export function tryGetAutoImportableReferenceFromTypeNode(importTypeNode: TypeNo
if (isLiteralImportTypeNode(node) && node.qualifier) {
// Symbol for the left-most thing after the dot
const firstIdentifier = getFirstIdentifier(node.qualifier);
if (!firstIdentifier.symbol) {
// if symbol is missing then this doesn't come from a synthesized import type node
// it has to be an import type node authored by the user and thus it has to be valid
// it can't refer to reserved internal symbol names and such
return visitEachChild(node, visit, /*context*/ undefined);
}
const name = getNameForExportedSymbol(firstIdentifier.symbol, scriptTarget);
const qualifier = name !== firstIdentifier.text
? replaceFirstIdentifierOfEntityName(node.qualifier, factory.createIdentifier(name))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/// <reference path="fourslash.ts" />

// @module: nodenext

// @Filename: /generation.d.ts
//// export type GenerationConfigType = { max_length?: number };

// @FileName: /index.d.ts
//// export declare class PreTrainedModel {
//// _get_generation_config(
//// param: import("./generation.js").GenerationConfigType,
//// ): import("./generation.js").GenerationConfigType;
//// }
////
//// export declare class BlenderbotSmallPreTrainedModel extends PreTrainedModel {
//// /*1*/
//// }

verify.completions({
marker: "1",
includes: [
{
name: "_get_generation_config",
insertText: `_get_generation_config(param: import("./generation.js").GenerationConfigType): import("./generation.js").GenerationConfigType;`,
filterText: "_get_generation_config",
hasAction: undefined,
},
],
preferences: {
includeCompletionsWithClassMemberSnippets: true,
includeCompletionsWithInsertText: true,
},
isNewIdentifierLocation: true,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/// <reference path="fourslash.ts" />

// @module: nodenext

// @FileName: /index.d.ts
//// export declare class Cls {
//// method(
//// param: import("./doesntexist.js").Foo,
//// ): import("./doesntexist.js").Foo;
//// }
////
//// export declare class Derived extends Cls {
//// /*1*/
//// }

verify.completions({
marker: "1",
includes: [
{
name: "method",
insertText: `method(param: import("./doesntexist.js").Foo);`,
filterText: "method",
hasAction: undefined,
},
],
preferences: {
includeCompletionsWithClassMemberSnippets: true,
includeCompletionsWithInsertText: true,
},
isNewIdentifierLocation: true,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference path="fourslash.ts" />

// @module: nodenext

// @FileName: /other/foo.d.ts
//// export declare type Bar = { baz: string };

// @FileName: /other/cls.d.ts
//// export declare class Cls {
//// method(
//// param: import("./foo.js").Bar,
//// ): import("./foo.js").Bar;
//// }

// @FileName: /index.d.ts
//// import { Cls } from "./other/cls.js";
////
//// export declare class Derived extends Cls {
//// /*1*/
//// }

verify.completions({
marker: "1",
includes: [
{
name: "method",
insertText: `method(param: import("./other/foo.js").Bar): import("./other/foo.js").Bar;`,
filterText: "method",
hasAction: undefined,
},
],
preferences: {
includeCompletionsWithClassMemberSnippets: true,
includeCompletionsWithInsertText: true,
},
isNewIdentifierLocation: true,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/// <reference path="fourslash.ts" />

// @module: nodenext

// @FileName: /other/cls.d.ts
//// export declare class Cls {
//// method(
//// param: import("./doesntexist.js").Foo,
//// ): import("./doesntexist.js").Foo;
//// }

// @FileName: /index.d.ts
//// import { Cls } from "./other/cls.js";
////
//// export declare class Derived extends Cls {
//// /*1*/
//// }

verify.completions({
marker: "1",
includes: [
{
name: "method",
insertText: `method(param: import("./doesntexist.js").Foo);`,
filterText: "method",
hasAction: undefined,
},
],
preferences: {
includeCompletionsWithClassMemberSnippets: true,
includeCompletionsWithInsertText: true,
},
isNewIdentifierLocation: true,
});