Fix incorrect relative module name detection (#19702)

This commit is contained in:
Mohamed Hegazy 2017-11-03 08:59:19 -07:00 committed by GitHub
parent d54ad4b01a
commit 1e89e78dd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 48 additions and 3 deletions

View File

@ -64,7 +64,6 @@ module Commands {
}
if (path.charAt(1) === ":") {
if (path.charAt(2) === directorySeparator) return 3;
return 2;
}
return 0;
}

View File

@ -1574,7 +1574,6 @@ namespace ts {
}
if (path.charCodeAt(1) === CharacterCodes.colon) {
if (path.charCodeAt(2) === CharacterCodes.slash) return 3;
return 2;
}
// Per RFC 1738 'file' URI schema has the shape file://<host>/<path>
// if <host> is omitted then it is assumed that host value is 'localhost',

View File

@ -0,0 +1,13 @@
tests/cases/compiler/declarationEmitRelativeModuleError.ts(5,16): error TS2436: Ambient module declaration cannot specify relative module name.
==== tests/cases/compiler/declarationEmitRelativeModuleError.ts (1 errors) ====
declare module "b:block" { // <-- no error anymore
}
declare module "b:/block" { // <-- still an error
~~~~~~~~~~
!!! error TS2436: Ambient module declaration cannot specify relative module name.
}

View File

@ -0,0 +1,10 @@
//// [declarationEmitRelativeModuleError.ts]
declare module "b:block" { // <-- no error anymore
}
declare module "b:/block" { // <-- still an error
}
//// [declarationEmitRelativeModuleError.js]

View File

@ -0,0 +1,9 @@
=== tests/cases/compiler/declarationEmitRelativeModuleError.ts ===
declare module "b:block" { // <-- no error anymore
No type information for this code.
No type information for this code.}
No type information for this code.
No type information for this code.declare module "b:/block" { // <-- still an error
No type information for this code.
No type information for this code.}
No type information for this code.

View File

@ -0,0 +1,9 @@
=== tests/cases/compiler/declarationEmitRelativeModuleError.ts ===
declare module "b:block" { // <-- no error anymore
No type information for this code.
No type information for this code.}
No type information for this code.
No type information for this code.declare module "b:/block" { // <-- still an error
No type information for this code.
No type information for this code.}
No type information for this code.

View File

@ -0,0 +1,7 @@
declare module "b:block" { // <-- no error anymore
}
declare module "b:/block" { // <-- still an error
}

View File

@ -61,7 +61,6 @@ function getRootLength(path: string): number {
}
if (path.charAt(1) === ":") {
if (path.charAt(2) === directorySeparator) return 3;
return 2;
}
// Per RFC 1738 'file' URI schema has the shape file://<host>/<path>
// if <host> is omitted then it is assumed that host value is 'localhost',