From 1e89e78dd213ee24036895508484d8ae9e18a657 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 3 Nov 2017 08:59:19 -0700 Subject: [PATCH] Fix incorrect relative module name detection (#19702) --- scripts/ior.ts | 1 - src/compiler/core.ts | 1 - .../declarationEmitRelativeModuleError.errors.txt | 13 +++++++++++++ .../reference/declarationEmitRelativeModuleError.js | 10 ++++++++++ .../declarationEmitRelativeModuleError.symbols | 9 +++++++++ .../declarationEmitRelativeModuleError.types | 9 +++++++++ .../compiler/declarationEmitRelativeModuleError.ts | 7 +++++++ tests/webTestServer.ts | 1 - 8 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/declarationEmitRelativeModuleError.errors.txt create mode 100644 tests/baselines/reference/declarationEmitRelativeModuleError.js create mode 100644 tests/baselines/reference/declarationEmitRelativeModuleError.symbols create mode 100644 tests/baselines/reference/declarationEmitRelativeModuleError.types create mode 100644 tests/cases/compiler/declarationEmitRelativeModuleError.ts diff --git a/scripts/ior.ts b/scripts/ior.ts index 91580203350..374747d8439 100644 --- a/scripts/ior.ts +++ b/scripts/ior.ts @@ -64,7 +64,6 @@ module Commands { } if (path.charAt(1) === ":") { if (path.charAt(2) === directorySeparator) return 3; - return 2; } return 0; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 23493b3087d..157a0c7fd1d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -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:/// // if is omitted then it is assumed that host value is 'localhost', diff --git a/tests/baselines/reference/declarationEmitRelativeModuleError.errors.txt b/tests/baselines/reference/declarationEmitRelativeModuleError.errors.txt new file mode 100644 index 00000000000..32aea83b5e4 --- /dev/null +++ b/tests/baselines/reference/declarationEmitRelativeModuleError.errors.txt @@ -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. + + } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitRelativeModuleError.js b/tests/baselines/reference/declarationEmitRelativeModuleError.js new file mode 100644 index 00000000000..e1d78ba5c03 --- /dev/null +++ b/tests/baselines/reference/declarationEmitRelativeModuleError.js @@ -0,0 +1,10 @@ +//// [declarationEmitRelativeModuleError.ts] +declare module "b:block" { // <-- no error anymore + +} + +declare module "b:/block" { // <-- still an error + +} + +//// [declarationEmitRelativeModuleError.js] diff --git a/tests/baselines/reference/declarationEmitRelativeModuleError.symbols b/tests/baselines/reference/declarationEmitRelativeModuleError.symbols new file mode 100644 index 00000000000..d07a145116a --- /dev/null +++ b/tests/baselines/reference/declarationEmitRelativeModuleError.symbols @@ -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. \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitRelativeModuleError.types b/tests/baselines/reference/declarationEmitRelativeModuleError.types new file mode 100644 index 00000000000..d07a145116a --- /dev/null +++ b/tests/baselines/reference/declarationEmitRelativeModuleError.types @@ -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. \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitRelativeModuleError.ts b/tests/cases/compiler/declarationEmitRelativeModuleError.ts new file mode 100644 index 00000000000..f358e81da43 --- /dev/null +++ b/tests/cases/compiler/declarationEmitRelativeModuleError.ts @@ -0,0 +1,7 @@ +declare module "b:block" { // <-- no error anymore + +} + +declare module "b:/block" { // <-- still an error + +} \ No newline at end of file diff --git a/tests/webTestServer.ts b/tests/webTestServer.ts index 5a3b4cc5048..aff2ba0752a 100644 --- a/tests/webTestServer.ts +++ b/tests/webTestServer.ts @@ -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:/// // if is omitted then it is assumed that host value is 'localhost',