From 2836c17791806d7be0db65dca7bdff8385bb0db0 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 23 Nov 2015 13:08:44 -0800 Subject: [PATCH 1/2] do not treat modules with '!' in names any specially --- src/compiler/checker.ts | 4 ---- tests/baselines/reference/bangInModuleName.js | 23 +++++++++++++++++++ .../reference/bangInModuleName.symbols | 21 +++++++++++++++++ .../reference/bangInModuleName.types | 21 +++++++++++++++++ tests/cases/compiler/bangInModuleName.ts | 17 ++++++++++++++ 5 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/bangInModuleName.js create mode 100644 tests/baselines/reference/bangInModuleName.symbols create mode 100644 tests/baselines/reference/bangInModuleName.types create mode 100644 tests/cases/compiler/bangInModuleName.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1b6b31f958697..c8e3b8381c3ec 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1034,10 +1034,6 @@ namespace ts { return; } - if (moduleName.indexOf("!") >= 0) { - moduleName = moduleName.substr(0, moduleName.indexOf("!")); - } - const isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { const symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule); diff --git a/tests/baselines/reference/bangInModuleName.js b/tests/baselines/reference/bangInModuleName.js new file mode 100644 index 0000000000000..769ccbf1d42b0 --- /dev/null +++ b/tests/baselines/reference/bangInModuleName.js @@ -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] + +/// + +import * as http from 'intern/dojo/node!http'; + +//// [a.js] +/// +define(["require", "exports"], function (require, exports) { +}); diff --git a/tests/baselines/reference/bangInModuleName.symbols b/tests/baselines/reference/bangInModuleName.symbols new file mode 100644 index 0000000000000..63ba5d106d800 --- /dev/null +++ b/tests/baselines/reference/bangInModuleName.symbols @@ -0,0 +1,21 @@ +=== tests/cases/compiler/a.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)) +} + diff --git a/tests/baselines/reference/bangInModuleName.types b/tests/baselines/reference/bangInModuleName.types new file mode 100644 index 0000000000000..06a602e2ff831 --- /dev/null +++ b/tests/baselines/reference/bangInModuleName.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/a.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 +} + diff --git a/tests/cases/compiler/bangInModuleName.ts b/tests/cases/compiler/bangInModuleName.ts new file mode 100644 index 0000000000000..6e8f7163109fa --- /dev/null +++ b/tests/cases/compiler/bangInModuleName.ts @@ -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 + +/// + +import * as http from 'intern/dojo/node!http'; \ No newline at end of file From 566c0db54313f864103054c536372a8908162a66 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 23 Nov 2015 13:24:46 -0800 Subject: [PATCH 2/2] fix lint errors --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c8e3b8381c3ec..d06b58cbecaec 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1028,7 +1028,7 @@ 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;