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
10 changes: 1 addition & 9 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3766,7 +3766,7 @@
"category": "Error",
"code": 90010
},
"Import '{0}' from \"{1}\".": {
"Import '{0}' from module \"{1}\".": {
"category": "Message",
"code": 90013
},
Expand Down Expand Up @@ -3886,13 +3886,5 @@
"Install '{0}'": {
"category": "Message",
"code": 95014
},
"Import '{0}' = require(\"{1}\").": {
"category": "Message",
"code": 95015
},
"Import * as '{0}' from \"{1}\".": {
"category": "Message",
"code": 95016
}
}
8 changes: 1 addition & 7 deletions src/services/codefixes/importFixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,11 @@ namespace ts.codefix {
}
});

const actionFormat = kind === ImportKind.Equals
? Diagnostics.Import_0_require_1
: kind === ImportKind.Namespace
? Diagnostics.Import_Asterisk_as_0_from_1
: Diagnostics.Import_0_from_1;

// if this file doesn't have any import statements, insert an import statement and then insert a new line
// between the only import statement and user code. Otherwise just insert the statement because chances
// are there are already a new line seperating code and import statements.
return createCodeAction(
actionFormat,
Diagnostics.Import_0_from_module_1,
[symbolName, moduleSpecifierWithoutQuotes],
changes,
"NewImport",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): vo
verify.applyCodeActionFromCompletion("", {
name: "foo",
source: "/a",
description: `Import 'foo' from "./a".`,
description: `Import 'foo' from module "./a".`,
// TODO: GH#18445
newFileContent: `import f_o_o from "./a";
import foo from "./a";\r
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ verify.completionListContains({ name: "fooBar", source: "/src/foo-bar" }, "(prop
verify.applyCodeActionFromCompletion("1", {
name: "fooBar",
source: "/src/foo-bar",
description: `Import 'fooBar' from "./foo-bar".`,
description: `Import 'fooBar' from module "./foo-bar".`,
// TODO: GH#18445
newFileContent: `import fooBar from "./foo-bar";\r
\r
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): vo
verify.applyCodeActionFromCompletion("", {
name: "foo",
source: "/a",
description: `Import 'foo' from "./a".`,
description: `Import 'foo' from module "./a".`,
// TODO: GH#18445
newFileContent: `import foo from "./a";\r
\r
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
verify.applyCodeActionFromCompletion("", {
name: "x",
source: "m",
description: `Import 'x' from "m".`,
description: `Import 'x' from module "m".`,
// TODO: GH#18445
newFileContent: `import { x } from "m";\r
\r
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ verify.completionListContains({ name: "foo", source: "/b" }, "const foo: 1", "",
verify.applyCodeActionFromCompletion("", {
name: "foo",
source: "/b",
description: `Import 'foo' from "./b".`,
description: `Import 'foo' from module "./b".`,
// TODO: GH#18445
newFileContent: `import { foo } from "./b";\r
\r
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): vo
verify.applyCodeActionFromCompletion("", {
name: "foo",
source: "/a",
description: `Import 'foo' from "./a".`,
description: `Import 'foo' from module "./a".`,
// TODO: GH#18445
newFileContent: `import * as a from "./a";
import { foo } from "./a";\r
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/fourslash/completionsImport_ofAlias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ verify.not.completionListContains({ name: "foo", source: "/a_reexport_2" }, unde
verify.applyCodeActionFromCompletion("", {
name: "foo",
source: "/a",
description: `Import 'foo' from "./a".`,
description: `Import 'foo' from module "./a".`,
// TODO: GH#18445
newFileContent: `import { foo } from "./a";\r
\r
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ verify.not.completionListContains({ name: "foo", source: "/foo/index" }, undefin
verify.applyCodeActionFromCompletion("", {
name: "foo",
source: "/foo/lib/foo",
description: `Import 'foo' from "./foo".`,
description: `Import 'foo' from module "./foo".`,
// TODO: GH#18445
newFileContent: `import { foo } from "./foo";\r
\r
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/fourslash/completionsImport_require.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "",
verify.applyCodeActionFromCompletion("b", {
name: "foo",
source: "/a",
description: `Import 'foo' from "./a".`,
description: `Import 'foo' from module "./a".`,
// TODO: GH#18445
newFileContent: `import { foo } from "./a";\r
\r
Expand All @@ -39,7 +39,7 @@ verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "",
verify.applyCodeActionFromCompletion("c", {
name: "foo",
source: "/a",
description: `Import 'foo' from "./a".`,
description: `Import 'foo' from module "./a".`,
// TODO: GH#18445
newFileContent: `import { foo } from "./a";\r
\r
Expand Down