Skip to content

Commit 1e89e78

Browse files
authored
Fix incorrect relative module name detection (#19702)
1 parent d54ad4b commit 1e89e78

8 files changed

+48
-3
lines changed

scripts/ior.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ module Commands {
6464
}
6565
if (path.charAt(1) === ":") {
6666
if (path.charAt(2) === directorySeparator) return 3;
67-
return 2;
6867
}
6968
return 0;
7069
}

src/compiler/core.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,6 @@ namespace ts {
15741574
}
15751575
if (path.charCodeAt(1) === CharacterCodes.colon) {
15761576
if (path.charCodeAt(2) === CharacterCodes.slash) return 3;
1577-
return 2;
15781577
}
15791578
// Per RFC 1738 'file' URI schema has the shape file://<host>/<path>
15801579
// if <host> is omitted then it is assumed that host value is 'localhost',
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
tests/cases/compiler/declarationEmitRelativeModuleError.ts(5,16): error TS2436: Ambient module declaration cannot specify relative module name.
2+
3+
4+
==== tests/cases/compiler/declarationEmitRelativeModuleError.ts (1 errors) ====
5+
declare module "b:block" { // <-- no error anymore
6+
7+
}
8+
9+
declare module "b:/block" { // <-- still an error
10+
~~~~~~~~~~
11+
!!! error TS2436: Ambient module declaration cannot specify relative module name.
12+
13+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//// [declarationEmitRelativeModuleError.ts]
2+
declare module "b:block" { // <-- no error anymore
3+
4+
}
5+
6+
declare module "b:/block" { // <-- still an error
7+
8+
}
9+
10+
//// [declarationEmitRelativeModuleError.js]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/compiler/declarationEmitRelativeModuleError.ts ===
2+
declare module "b:block" { // <-- no error anymore
3+
No type information for this code.
4+
No type information for this code.}
5+
No type information for this code.
6+
No type information for this code.declare module "b:/block" { // <-- still an error
7+
No type information for this code.
8+
No type information for this code.}
9+
No type information for this code.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/compiler/declarationEmitRelativeModuleError.ts ===
2+
declare module "b:block" { // <-- no error anymore
3+
No type information for this code.
4+
No type information for this code.}
5+
No type information for this code.
6+
No type information for this code.declare module "b:/block" { // <-- still an error
7+
No type information for this code.
8+
No type information for this code.}
9+
No type information for this code.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
declare module "b:block" { // <-- no error anymore
2+
3+
}
4+
5+
declare module "b:/block" { // <-- still an error
6+
7+
}

tests/webTestServer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ function getRootLength(path: string): number {
6161
}
6262
if (path.charAt(1) === ":") {
6363
if (path.charAt(2) === directorySeparator) return 3;
64-
return 2;
6564
}
6665
// Per RFC 1738 'file' URI schema has the shape file://<host>/<path>
6766
// if <host> is omitted then it is assumed that host value is 'localhost',

0 commit comments

Comments
 (0)