Merge pull request #5759 from Microsoft/bangInModuleNames

do not treat modules with '!' in names any specially
This commit is contained in:
Vladimir Matveev 2015-11-23 14:08:33 -08:00
commit fb76dc95de
5 changed files with 83 additions and 5 deletions

View File

@ -1028,16 +1028,12 @@ namespace ts {
// Module names are escaped in our symbol table. However, string literal values aren't.
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
let moduleName = escapeIdentifier(moduleReferenceLiteral.text);
const moduleName = escapeIdentifier(moduleReferenceLiteral.text);
if (moduleName === undefined) {
return;
}
if (moduleName.indexOf("!") >= 0) {
moduleName = moduleName.substr(0, moduleName.indexOf("!"));
}
const isRelative = isExternalModuleNameRelative(moduleName);
if (!isRelative) {
const symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule);

View File

@ -0,0 +1,23 @@
//// [tests/cases/compiler/bangInModuleName.ts] ////
//// [a.d.ts]
declare module "http" {
}
declare module 'intern/dojo/node!http' {
import http = require('http');
export = http;
}
//// [a.ts]
/// <reference path="a.d.ts"/>
import * as http from 'intern/dojo/node!http';
//// [a.js]
/// <reference path="a.d.ts"/>
define(["require", "exports"], function (require, exports) {
});

View File

@ -0,0 +1,21 @@
=== tests/cases/compiler/a.ts ===
/// <reference path="a.d.ts"/>
import * as http from 'intern/dojo/node!http';
>http : Symbol(http, Decl(a.ts, 3, 6))
=== tests/cases/compiler/a.d.ts ===
declare module "http" {
}
declare module 'intern/dojo/node!http' {
import http = require('http');
>http : Symbol(http, Decl(a.d.ts, 5, 40))
export = http;
>http : Symbol(http, Decl(a.d.ts, 5, 40))
}

View File

@ -0,0 +1,21 @@
=== tests/cases/compiler/a.ts ===
/// <reference path="a.d.ts"/>
import * as http from 'intern/dojo/node!http';
>http : typeof http
=== tests/cases/compiler/a.d.ts ===
declare module "http" {
}
declare module 'intern/dojo/node!http' {
import http = require('http');
>http : typeof http
export = http;
>http : typeof http
}

View File

@ -0,0 +1,17 @@
// @module: amd
// @filename: a.d.ts
declare module "http" {
}
declare module 'intern/dojo/node!http' {
import http = require('http');
export = http;
}
// @filename: a.ts
/// <reference path="a.d.ts"/>
import * as http from 'intern/dojo/node!http';