Skip to content

Commit fb76dc9

Browse files
committed
Merge pull request #5759 from Microsoft/bangInModuleNames
do not treat modules with '!' in names any specially
2 parents 262bdb5 + 566c0db commit fb76dc9

File tree

5 files changed

+83
-5
lines changed

5 files changed

+83
-5
lines changed

Diff for: src/compiler/checker.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -1028,16 +1028,12 @@ namespace ts {
10281028

10291029
// Module names are escaped in our symbol table. However, string literal values aren't.
10301030
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
1031-
let moduleName = escapeIdentifier(moduleReferenceLiteral.text);
1031+
const moduleName = escapeIdentifier(moduleReferenceLiteral.text);
10321032

10331033
if (moduleName === undefined) {
10341034
return;
10351035
}
10361036

1037-
if (moduleName.indexOf("!") >= 0) {
1038-
moduleName = moduleName.substr(0, moduleName.indexOf("!"));
1039-
}
1040-
10411037
const isRelative = isExternalModuleNameRelative(moduleName);
10421038
if (!isRelative) {
10431039
const symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule);

Diff for: tests/baselines/reference/bangInModuleName.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//// [tests/cases/compiler/bangInModuleName.ts] ////
2+
3+
//// [a.d.ts]
4+
5+
6+
declare module "http" {
7+
}
8+
9+
declare module 'intern/dojo/node!http' {
10+
import http = require('http');
11+
export = http;
12+
}
13+
14+
//// [a.ts]
15+
16+
/// <reference path="a.d.ts"/>
17+
18+
import * as http from 'intern/dojo/node!http';
19+
20+
//// [a.js]
21+
/// <reference path="a.d.ts"/>
22+
define(["require", "exports"], function (require, exports) {
23+
});

Diff for: tests/baselines/reference/bangInModuleName.symbols

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
=== tests/cases/compiler/a.ts ===
2+
3+
/// <reference path="a.d.ts"/>
4+
5+
import * as http from 'intern/dojo/node!http';
6+
>http : Symbol(http, Decl(a.ts, 3, 6))
7+
8+
=== tests/cases/compiler/a.d.ts ===
9+
10+
11+
declare module "http" {
12+
}
13+
14+
declare module 'intern/dojo/node!http' {
15+
import http = require('http');
16+
>http : Symbol(http, Decl(a.d.ts, 5, 40))
17+
18+
export = http;
19+
>http : Symbol(http, Decl(a.d.ts, 5, 40))
20+
}
21+

Diff for: tests/baselines/reference/bangInModuleName.types

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
=== tests/cases/compiler/a.ts ===
2+
3+
/// <reference path="a.d.ts"/>
4+
5+
import * as http from 'intern/dojo/node!http';
6+
>http : typeof http
7+
8+
=== tests/cases/compiler/a.d.ts ===
9+
10+
11+
declare module "http" {
12+
}
13+
14+
declare module 'intern/dojo/node!http' {
15+
import http = require('http');
16+
>http : typeof http
17+
18+
export = http;
19+
>http : typeof http
20+
}
21+

Diff for: tests/cases/compiler/bangInModuleName.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// @module: amd
2+
3+
// @filename: a.d.ts
4+
5+
declare module "http" {
6+
}
7+
8+
declare module 'intern/dojo/node!http' {
9+
import http = require('http');
10+
export = http;
11+
}
12+
13+
// @filename: a.ts
14+
15+
/// <reference path="a.d.ts"/>
16+
17+
import * as http from 'intern/dojo/node!http';

0 commit comments

Comments
 (0)