Skip to content

Commit f078c2b

Browse files
committed
Report network paths in paths substitutions
Module resolution refuses to read network paths, so a network `paths` substitution only produced an unhelpful resolution failure. Report it where it is written in the config instead.
1 parent c6f5e66 commit f078c2b

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

‎tsc/internal/compiler/program.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/microsoft/TypeScript/tsc/internal/locale"
2222
"github.com/microsoft/TypeScript/tsc/internal/module"
2323
"github.com/microsoft/TypeScript/tsc/internal/modulespecifiers"
24+
"github.com/microsoft/TypeScript/tsc/internal/nativepath"
2425
"github.com/microsoft/TypeScript/tsc/internal/outputpaths"
2526
"github.com/microsoft/TypeScript/tsc/internal/packagejson"
2627
"github.com/microsoft/TypeScript/tsc/internal/parser"
@@ -1181,6 +1182,8 @@ func (p *Program) verifyCompilerOptions() {
11811182
}
11821183
if !tspath.PathIsRelative(subst) && !tspath.PathIsAbsolute(subst) {
11831184
createDiagnosticForOptionPathKeyValue(key, i, diagnostics.Non_relative_paths_are_not_allowed_Did_you_forget_a_leading_Slash)
1185+
} else if nativepath.IsNetworkPath(tspath.GetNormalizedAbsolutePath(subst, options.GetPathsBasePath(p.GetCurrentDirectory()))) {
1186+
createDiagnosticForOptionPathKeyValue(key, i, diagnostics.Network_path_0_is_not_supported, subst)
11841187
}
11851188
}
11861189
}

‎tsc/testdata/baselines/reference/compiler/networkPathReferences.errors.txt‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,24 @@
22
/main.ts(2,22): error TS5116: Network path '//server/share/types.d.ts' is not supported.
33
/main.ts(3,22): error TS5116: Network path '//?/UNC/server/share/types.d.ts' is not supported.
44
/main.ts(4,22): error TS5116: Network path '/??/UNC/server/share/types.d.ts' is not supported.
5+
/tsconfig.json(4,24): error TS5116: Network path '//server/share/remote.d.ts' is not supported.
56

67

8+
==== /tsconfig.json (1 errors) ====
9+
{
10+
"compilerOptions": {
11+
"paths": {
12+
"remote": ["//server/share/remote.d.ts", "./share/types.d.ts"],
13+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14+
!!! error TS5116: Network path '//server/share/remote.d.ts' is not supported.
15+
"local": ["/??/../share/types.d.ts"]
16+
}
17+
}
18+
}
19+
20+
==== /share/types.d.ts (0 errors) ====
21+
export declare const x: number;
22+
723
==== /main.ts (4 errors) ====
824
/// <reference path="//server/share/types.d.ts" />
925
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -20,7 +36,4 @@
2036
/// <reference path="./share/types.d.ts" />
2137
import { x } from "./share/types";
2238
x;
23-
24-
==== /share/types.d.ts (0 errors) ====
25-
export declare const x: number;
2639

‎tsc/testdata/tests/cases/compiler/networkPathReferences.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
// @module: preserve
33
// @noTypesAndSymbols: true
44

5+
// @filename: /tsconfig.json
6+
{
7+
"compilerOptions": {
8+
"paths": {
9+
"remote": ["//server/share/remote.d.ts", "./share/types.d.ts"],
10+
"local": ["/??/../share/types.d.ts"]
11+
}
12+
}
13+
}
14+
515
// @filename: /share/types.d.ts
616
export declare const x: number;
717

0 commit comments

Comments
 (0)