Skip to content

Commit 17ffcd2

Browse files
authored
(fix): templates should not have baseUrl or paths set (#707)
- there are many issues about TS path aliases not fully "working", so they should be removed from the templates until they are completely "working" - instead of shipping templates with a partially "broken" and confusing configuration enabled - especially confusing to users because editors will auto-complete with the absolute path instead of the relative path - and the fact that these paths are unresolved at build or test time means that it's not understood that this is "broken" until later in the process - this is a *very* common misconception with TS users that `paths` rewrites/transforms imports during compilation, but it actually does not change any absolute paths to relative, it leaves them as is - it just resolves type information to help on platforms that import differently - basically, it's somewhat of a legacy option, but folks think it's used for aliases and does transforms - and folks seem to want it to work that way too - it actually does the reverse, it supports the usage of aliases/import rewrites elsewhere - unfortunately this misconception made its way into the very first template, causing lots of confusion and issues reported since - so `paths` isn't "broken" per se, it just doesn't do what people think it does (including template authors) - well it *is* broken for standard TSDX usage out-of-the-box - since TSDX doesn't output for platforms where it makes sense out-of-the-box - as a result, for aliases to be fully supported by TSDX, we'd have to add some sort of transformation(s) for build, test, and lint - until then this shouldn't be in the templates - but don't give an error on it because there are methods/"workarounds" to support aliasing/import rewrites using the configuration in `paths` - and if one is using import rewrites, `paths` is necessary for TS to not give errors - also removes an inconsistency in the Storybook template that used "@/*" as an alias, even though the other templates didn't have that - while this is a supported alias by some libraries in the community, - oversight in code review when Storybook templates were added and caused some confusion for users - also removes these options from all test fixtures
1 parent 35f162a commit 17ffcd2

11 files changed

Lines changed: 0 additions & 39 deletions

File tree

templates/basic/tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
"noImplicitReturns": true,
1414
"noFallthroughCasesInSwitch": true,
1515
"moduleResolution": "node",
16-
"baseUrl": "./",
17-
"paths": {
18-
"*": ["src/*", "node_modules/*"]
19-
},
2016
"jsx": "react",
2117
"esModuleInterop": true
2218
}

templates/react-with-storybook/example/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"preserveConstEnums": true,
1414
"sourceMap": true,
1515
"lib": ["es2015", "es2016", "dom"],
16-
"baseUrl": ".",
1716
"types": ["node"]
1817
}
1918
}

templates/react-with-storybook/tsconfig.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
"noImplicitReturns": true,
1414
"noFallthroughCasesInSwitch": true,
1515
"moduleResolution": "node",
16-
"baseUrl": "./",
17-
"paths": {
18-
"@": ["./"],
19-
"*": ["src/*", "node_modules/*"]
20-
},
2116
"jsx": "react",
2217
"esModuleInterop": true
2318
}

templates/react/example/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"preserveConstEnums": true,
1414
"sourceMap": true,
1515
"lib": ["es2015", "es2016", "dom"],
16-
"baseUrl": ".",
1716
"types": ["node"]
1817
}
1918
}

templates/react/tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
"noImplicitReturns": true,
1414
"noFallthroughCasesInSwitch": true,
1515
"moduleResolution": "node",
16-
"baseUrl": "./",
17-
"paths": {
18-
"*": ["src/*", "node_modules/*"]
19-
},
2016
"jsx": "react",
2117
"esModuleInterop": true
2218
}

test/e2e/fixtures/build-default/tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
"noImplicitReturns": true,
1212
"noFallthroughCasesInSwitch": true,
1313
"moduleResolution": "node",
14-
"baseUrl": "./",
15-
"paths": {
16-
"*": ["src/*", "node_modules/*"]
17-
},
1814
"jsx": "react",
1915
"esModuleInterop": true
2016
},

test/e2e/fixtures/build-invalid/tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
"noImplicitReturns": true,
1212
"noFallthroughCasesInSwitch": true,
1313
"moduleResolution": "node",
14-
"baseUrl": "./",
15-
"paths": {
16-
"*": ["src/*", "node_modules/*"]
17-
},
1814
"jsx": "react",
1915
"esModuleInterop": true
2016
},

test/e2e/fixtures/build-withTsconfig/tsconfig.base.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
"noImplicitReturns": true,
1414
"noFallthroughCasesInSwitch": true,
1515
"moduleResolution": "node",
16-
"baseUrl": "./",
17-
"paths": {
18-
"*": ["src/*", "node_modules/*"]
19-
},
2016
"jsx": "react",
2117
"esModuleInterop": false
2218
},

test/integration/fixtures/build-options/tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
"noImplicitReturns": true,
1212
"noFallthroughCasesInSwitch": true,
1313
"moduleResolution": "node",
14-
"baseUrl": "./",
15-
"paths": {
16-
"*": ["src/*", "node_modules/*"]
17-
},
1814
"jsx": "react",
1915
"esModuleInterop": true
2016
},

test/integration/fixtures/build-withBabel/tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
"noImplicitReturns": true,
1212
"noFallthroughCasesInSwitch": true,
1313
"moduleResolution": "node",
14-
"baseUrl": "./",
15-
"paths": {
16-
"*": ["src/*", "node_modules/*"]
17-
},
1814
"jsx": "react",
1915
"esModuleInterop": true
2016
},

0 commit comments

Comments
 (0)