Skip to content

do not treat modules with '!' in names any specially #5759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 23, 2015
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
6 changes: 1 addition & 5 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 23 additions & 0 deletions tests/baselines/reference/bangInModuleName.js
Original file line number Diff line number Diff line change
@@ -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) {
});
21 changes: 21 additions & 0 deletions tests/baselines/reference/bangInModuleName.symbols
Original file line number Diff line number Diff line change
@@ -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))
}

21 changes: 21 additions & 0 deletions tests/baselines/reference/bangInModuleName.types
Original file line number Diff line number Diff line change
@@ -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
}

17 changes: 17 additions & 0 deletions tests/cases/compiler/bangInModuleName.ts
Original file line number Diff line number Diff line change
@@ -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';