Skip to content

Commit 853937e

Browse files
committed
Merge branch 'master' of https://github.com/Microsoft/TypeScript into import-fix-add-import-require-support
2 parents 57fdca2 + 2fcf8b7 commit 853937e

File tree

7 files changed

+87
-5
lines changed

7 files changed

+87
-5
lines changed

src/compiler/utilities.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,10 @@ namespace ts {
363363
case SyntaxKind.NoSubstitutionTemplateLiteral:
364364
return "`" + escapeText(node.text, CharacterCodes.backtick) + "`";
365365
case SyntaxKind.TemplateHead:
366+
// tslint:disable-next-line no-invalid-template-strings
366367
return "`" + escapeText(node.text, CharacterCodes.backtick) + "${";
367368
case SyntaxKind.TemplateMiddle:
369+
// tslint:disable-next-line no-invalid-template-strings
368370
return "}" + escapeText(node.text, CharacterCodes.backtick) + "${";
369371
case SyntaxKind.TemplateTail:
370372
return "}" + escapeText(node.text, CharacterCodes.backtick) + "`";

src/harness/unittests/printer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ namespace ts {
5555
printsCorrectly("removeComments", { removeComments: true }, printer => printer.printFile(sourceFile));
5656

5757
// github #14948
58+
// tslint:disable-next-line no-invalid-template-strings
5859
printsCorrectly("templateLiteral", {}, printer => printer.printFile(createSourceFile("source.ts", "let greeting = `Hi ${name}, how are you?`;", ScriptTarget.ES2017)));
5960

6061
// github #18071

src/harness/unittests/services/colorization.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/// <reference path="..\..\harnessLanguageService.ts" />
22

3+
// tslint:disable no-invalid-template-strings (lots of tests use quoted code)
4+
35
interface ClassificationEntry {
46
value: any;
57
classification: ts.TokenClass;

src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,6 +2241,15 @@
22412241
</Str>
22422242
<Disp Icon="Str" />
22432243
</Item>
2244+
<Item ItemId=";Convert_to_default_import_95013" ItemType="0" PsrId="306" Leaf="true">
2245+
<Str Cat="Text">
2246+
<Val><![CDATA[Convert to default import]]></Val>
2247+
<Tgt Cat="Text" Stat="Loc" Orig="New">
2248+
<Val><![CDATA[기본 가져오기로 변환]]></Val>
2249+
</Tgt>
2250+
</Str>
2251+
<Disp Icon="Str" />
2252+
</Item>
22442253
<Item ItemId=";Corrupted_locale_file_0_6051" ItemType="0" PsrId="306" Leaf="true">
22452254
<Str Cat="Text">
22462255
<Val><![CDATA[Corrupted locale file {0}.]]></Val>
@@ -2970,6 +2979,15 @@
29702979
</Str>
29712980
<Disp Icon="Str" />
29722981
</Item>
2982+
<Item ItemId=";Expected_corresponding_closing_tag_for_JSX_fragment_17015" ItemType="0" PsrId="306" Leaf="true">
2983+
<Str Cat="Text">
2984+
<Val><![CDATA[Expected corresponding closing tag for JSX fragment.]]></Val>
2985+
<Tgt Cat="Text" Stat="Loc" Orig="New">
2986+
<Val><![CDATA[JSX 조각에 닫는 태그가 필요합니다.]]></Val>
2987+
</Tgt>
2988+
</Str>
2989+
<Disp Icon="Str" />
2990+
</Item>
29732991
<Item ItemId=";Expected_type_of_0_field_in_package_json_to_be_string_got_1_6105" ItemType="0" PsrId="306" Leaf="true">
29742992
<Str Cat="Text">
29752993
<Val><![CDATA[Expected type of '{0}' field in 'package.json' to be 'string', got '{1}'.]]></Val>
@@ -4212,6 +4230,24 @@
42124230
</Str>
42134231
<Disp Icon="Str" />
42144232
</Item>
4233+
<Item ItemId=";JSX_fragment_has_no_corresponding_closing_tag_17014" ItemType="0" PsrId="306" Leaf="true">
4234+
<Str Cat="Text">
4235+
<Val><![CDATA[JSX fragment has no corresponding closing tag.]]></Val>
4236+
<Tgt Cat="Text" Stat="Loc" Orig="New">
4237+
<Val><![CDATA[JSX 조각에 닫는 태그가 없습니다.]]></Val>
4238+
</Tgt>
4239+
</Str>
4240+
<Disp Icon="Str" />
4241+
</Item>
4242+
<Item ItemId=";JSX_fragment_is_not_supported_when_using_jsxFactory_17016" ItemType="0" PsrId="306" Leaf="true">
4243+
<Str Cat="Text">
4244+
<Val><![CDATA[JSX fragment is not supported when using --jsxFactory]]></Val>
4245+
<Tgt Cat="Text" Stat="Loc" Orig="New">
4246+
<Val><![CDATA[JSX 조각은 --jsxFactory를 사용하는 경우 지원되지 않습니다.]]></Val>
4247+
</Tgt>
4248+
</Str>
4249+
<Disp Icon="Str" />
4250+
</Item>
42154251
<Item ItemId=";JSX_spread_child_must_be_an_array_type_2609" ItemType="0" PsrId="306" Leaf="true">
42164252
<Str Cat="Text">
42174253
<Val><![CDATA[JSX spread child must be an array type.]]></Val>

src/services/codefixes/importFixes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,12 @@ namespace ts.codefix {
238238
return parent as ImportDeclaration;
239239
case SyntaxKind.ExternalModuleReference:
240240
return (parent as ExternalModuleReference).parent;
241-
case SyntaxKind.ImportEqualsDeclaration:
242-
return parent as ImportEqualsDeclaration;
243-
default:
244-
Debug.assert(parent.kind === SyntaxKind.ExportDeclaration);
241+
case SyntaxKind.ExportDeclaration:
242+
case SyntaxKind.CallExpression: // For "require()" calls
245243
// Ignore these, can't add imports to them.
246244
return undefined;
245+
default:
246+
Debug.fail();
247247
}
248248
}
249249

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowJs: true
4+
5+
// @Filename: /a.ts
6+
////export const foo = 0;
7+
8+
// @Filename: /b.js
9+
////const a = require("./a");
10+
////fo/*b*/
11+
12+
// @Filename: /c.js
13+
////const a = import("./a");
14+
////fo/*c*/
15+
16+
goTo.marker("b");
17+
verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true });
18+
19+
verify.applyCodeActionFromCompletion("b", {
20+
name: "foo",
21+
source: "/a",
22+
description: `Import 'foo' from "./a".`,
23+
// TODO: GH#18445
24+
newFileContent: `import { foo } from "./a";\r
25+
\r
26+
const a = require("./a");
27+
fo`,
28+
});
29+
30+
goTo.marker("c");
31+
verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true });
32+
33+
verify.applyCodeActionFromCompletion("c", {
34+
name: "foo",
35+
source: "/a",
36+
description: `Import 'foo' from "./a".`,
37+
// TODO: GH#18445
38+
newFileContent: `import { foo } from "./a";\r
39+
\r
40+
const a = import("./a");
41+
fo`,
42+
});

tslint.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
"no-empty": false,
9090
"no-empty-interface": false,
9191
"no-eval": false,
92-
"no-invalid-template-strings": false,
9392
"no-object-literal-type-assertion": false,
9493
"no-shadowed-variable": false,
9594
"no-submodule-imports": false,

0 commit comments

Comments
 (0)