Skip to content

Override diagnostic about baseUrl path checks #1407

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 5 commits into from
Jul 21, 2025
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
3 changes: 1 addition & 2 deletions internal/compiler/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,7 @@ func (p *Program) verifyCompilerOptions() {
createDiagnosticForOptionPathKeyValue(key, i, diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key)
}
if !tspath.PathIsRelative(subst) && !tspath.PathIsAbsolute(subst) {
// !!! This needs a better message that doesn't mention baseUrl
createDiagnosticForOptionPathKeyValue(key, i, diagnostics.Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash)
createDiagnosticForOptionPathKeyValue(key, i, diagnostics.Non_relative_paths_are_not_allowed_Did_you_forget_a_leading_Slash)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/diagnostics/diagnostics_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions internal/diagnostics/extraDiagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
"Generate pprof CPU/memory profiles to the given directory.": {
"category": "Message",
"code": 100002
},
"Non-relative paths are not allowed. Did you forget a leading './'?": {
"category": "Error",
"code": 5090
}
}
18 changes: 10 additions & 8 deletions internal/diagnostics/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,9 @@ func main() {
filename = filepath.FromSlash(filename) // runtime.Caller always returns forward slashes; https://go.dev/issues/3335, https://go.dev/cl/603275

rawExtraMessages := readRawMessages(filepath.Join(filepath.Dir(filename), "extraDiagnosticMessages.json"))
maps.Copy(rawDiagnosticMessages, rawExtraMessages)

diagnosticMessages := make([]*diagnosticMessage, 0, len(rawDiagnosticMessages))
for k, v := range rawDiagnosticMessages {
v.key = k
diagnosticMessages = append(diagnosticMessages, v)
}
maps.Copy(rawDiagnosticMessages, rawExtraMessages)
diagnosticMessages := slices.Collect(maps.Values(rawDiagnosticMessages))

slices.SortFunc(diagnosticMessages, func(a *diagnosticMessage, b *diagnosticMessage) int {
return cmp.Compare(a.Code, b.Code)
Expand Down Expand Up @@ -103,7 +99,7 @@ func main() {
}
}

func readRawMessages(p string) map[string]*diagnosticMessage {
func readRawMessages(p string) map[int]*diagnosticMessage {
file, err := os.Open(p)
if err != nil {
log.Fatalf("failed to open file: %v", err)
Expand All @@ -117,7 +113,13 @@ func readRawMessages(p string) map[string]*diagnosticMessage {
return nil
}

return rawMessages
codeToMessage := make(map[int]*diagnosticMessage, len(rawMessages))
for k, m := range rawMessages {
m.key = k
codeToMessage[m.Code] = m
}

return codeToMessage
}

var (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/tsconfig.json(6,3): error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration.
Use '"paths": {"*": "./*"}' instead.
/tsconfig.json(11,14): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
/tsconfig.json(11,14): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?


==== /tsconfig.json (2 errors) ====
Expand All @@ -19,7 +19,7 @@
"paths": {
"foo/*": ["node_modules/foo/lib/*"]
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/tsconfig.json(9,3): error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration.
Use '"paths": {"*": "./*"}' instead.
/tsconfig.json(11,21): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
/tsconfig.json(12,23): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
/tsconfig.json(11,21): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
/tsconfig.json(12,23): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?


==== /tsconfig.json (3 errors) ====
Expand All @@ -20,10 +20,10 @@
"paths": {
"some-library": ["node_modules/some-library/lib"],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
"some-library/*": ["node_modules/some-library/lib/*"]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
c:/root/tsconfig.json(5,17): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
c:/root/tsconfig.json(6,17): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
c:/root/tsconfig.json(5,17): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
c:/root/tsconfig.json(6,17): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?


==== c:/root/tsconfig.json (2 errors) ====
Expand All @@ -9,10 +9,10 @@ c:/root/tsconfig.json(6,17): error TS5090: Non-relative paths are not allowed wh
"*": [
"*",
~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
"generated/*"
~~~~~~~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
]
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--- old.pathMappingBasedModuleResolution1_node.errors.txt
+++ new.pathMappingBasedModuleResolution1_node.errors.txt
@@= skipped -0, +0 lines =@@
-c:/root/tsconfig.json(5,17): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
-c:/root/tsconfig.json(6,17): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
+c:/root/tsconfig.json(5,17): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
+c:/root/tsconfig.json(6,17): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?


==== c:/root/tsconfig.json (2 errors) ====
@@= skipped -8, +8 lines =@@
"*": [
"*",
~~~
-!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
+!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
"generated/*"
~~~~~~~~~~~~~
-!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
+!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ root/tsconfig.json(3,9): error TS5102: Option 'baseUrl' has been removed. Please
Use '"paths": {"*": "./src/*"}' instead.
root/tsconfig.json(5,13): error TS5061: Pattern '*1*' can have at most one '*' character.
root/tsconfig.json(5,22): error TS5062: Substitution '*2*' in pattern '*1*' can have at most one '*' character.
root/tsconfig.json(5,22): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
root/tsconfig.json(5,22): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?


==== root/tsconfig.json (4 errors) ====
Expand All @@ -19,7 +19,7 @@ root/tsconfig.json(5,22): error TS5090: Non-relative paths are not allowed when
~~~~~
!!! error TS5062: Substitution '*2*' in pattern '*1*' can have at most one '*' character.
~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
c:/root/tsconfig.json(3,9): error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration.
Use '"paths": {"*": "./*"}' instead.
c:/root/tsconfig.json(6,17): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
c:/root/tsconfig.json(7,17): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
c:/root/tsconfig.json(10,21): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
c:/root/tsconfig.json(6,17): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
c:/root/tsconfig.json(7,17): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
c:/root/tsconfig.json(10,21): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?


==== c:/root/tsconfig.json (4 errors) ====
Expand All @@ -16,15 +16,15 @@ c:/root/tsconfig.json(10,21): error TS5090: Non-relative paths are not allowed w
"*": [
"*",
~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
"generated/*"
~~~~~~~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
],
"components/*": [
"shared/components/*"
~~~~~~~~~~~~~~~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
]
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
c:/root/src/file1.ts(1,17): error TS2307: Cannot find module './project/file2' or its corresponding type declarations.
c:/root/src/tsconfig.json(3,9): error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration.
Use '"paths": {"*": "./../*"}' instead.
c:/root/src/tsconfig.json(6,17): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
c:/root/src/tsconfig.json(10,17): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
c:/root/src/tsconfig.json(6,17): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
c:/root/src/tsconfig.json(10,17): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?


==== c:/root/src/tsconfig.json (3 errors) ====
Expand All @@ -16,13 +16,13 @@ c:/root/src/tsconfig.json(10,17): error TS5090: Non-relative paths are not allow
"*": [
"*",
~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
"c:/shared/*"
],
"templates/*": [
"generated/src/templates/*"
~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
]
},
"rootDirs": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
c:/root/tsconfig.json(3,9): error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration.
Use '"paths": {"*": "./*"}' instead.
c:/root/tsconfig.json(6,16): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
c:/root/tsconfig.json(6,16): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?


==== c:/root/tsconfig.json (2 errors) ====
Expand All @@ -14,7 +14,7 @@ c:/root/tsconfig.json(6,16): error TS5090: Non-relative paths are not allowed wh
"@speedy/*/testing": [
"*/dist/index.ts"
~~~~~~~~~~~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
]
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/tsconfig.json(3,9): error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration.
Use '"paths": {"*": "./*"}' instead.
/tsconfig.json(5,21): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
/tsconfig.json(6,21): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
/tsconfig.json(5,21): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
/tsconfig.json(6,21): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?


==== /tsconfig.json (3 errors) ====
Expand All @@ -14,10 +14,10 @@
"paths": {
"foo": ["foo/foo.ts"],
~~~~~~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
"bar": ["bar/bar.js"]
~~~~~~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
},
"allowJs": true,
"outDir": "bin"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/tsconfig.json(3,9): error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration.
Use '"paths": {"*": "./*"}' instead.
/tsconfig.json(5,19): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
/tsconfig.json(5,19): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?


==== /tsconfig.json (2 errors) ====
Expand All @@ -13,7 +13,7 @@
"paths": {
"*": ["foo/*"]
~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/tsconfig.json(3,9): error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration.
Use '"paths": {"*": "./*"}' instead.
/tsconfig.json(5,19): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
/tsconfig.json(5,37): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
/tsconfig.json(5,19): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
/tsconfig.json(5,37): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?


==== /tsconfig.json (3 errors) ====
Expand All @@ -14,9 +14,9 @@
"paths": {
"*": ["node_modules/*", "src/types"]
~~~~~~~~~~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
~~~~~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
},
"allowJs": true,
"outDir": "bin"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/a.ts(1,21): error TS2307: Cannot find module 'foo' or its corresponding type declarations.
/tsconfig.json(3,9): error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration.
Use '"paths": {"*": "./*"}' instead.
/tsconfig.json(5,21): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
/tsconfig.json(5,21): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?


==== /tsconfig.json (2 errors) ====
Expand All @@ -14,7 +14,7 @@
"paths": {
"foo": ["foo/foo.ts"]
~~~~~~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ tsconfig.json(4,9): error TS5102: Option 'baseUrl' has been removed. Please remo
tsconfig.json(6,11): error TS5061: Pattern '@interface/**/*' can have at most one '*' character.
tsconfig.json(7,11): error TS5061: Pattern '@service/**/*' can have at most one '*' character.
tsconfig.json(7,29): error TS5062: Substitution './src/service/**/*' in pattern '@service/**/*' can have at most one '*' character.
tsconfig.json(8,29): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
tsconfig.json(8,29): error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?


==== tsconfig.json (5 errors) ====
Expand All @@ -25,7 +25,7 @@ tsconfig.json(8,29): error TS5090: Non-relative paths are not allowed when 'base
!!! error TS5062: Substitution './src/service/**/*' in pattern '@service/**/*' can have at most one '*' character.
"@controller/*": ["controller/*"],
~~~~~~~~~~~~~~
!!! error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
!!! error TS5090: Non-relative paths are not allowed. Did you forget a leading './'?
}
}
}
Expand Down
Loading
Loading