Skip to content

Commit 31c6ae7

Browse files
committed
remove tsconfig aliases
as typescript reuses package.json import config
1 parent 22145a8 commit 31c6ae7

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

docs/decisions/031-imports.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,14 @@ and manually modify.
2727
Despite the magic of Path aliases, they are actually a standard `package.json`
2828
supported feature. Sort of.
2929
[The `"imports"` field](https://nodejs.org/api/packages.html#imports) in
30-
`package.json` allows you to configure aliases for your imports. It's not
31-
exactly the same as TypeScript Path aliases, and using them doesn't give you
32-
autocomplete with TypeScript
33-
([yet](https://github.com/microsoft/TypeScript/pull/55015)), but if you
34-
configure both, then you can get the best of both worlds!
30+
`package.json` allows you to configure aliases for your imports.
31+
TypeScript also uses this for its own Path aliases since version 5.4
32+
so you get autocomplete and type checking for your imports.
3533

3634
By using the `"imports"` field, you don't have to do any special configuration
3735
for `vitest` or `eslint` to be able to resolve imports. They just resolve them
3836
using the standard.
3937

40-
And by using the `tsconfig.json` `paths` field configured in the same way as the
41-
`"imports"` field, you get autocomplete and type checking for your imports. This
42-
should hopefully be temporary until TypeScript supports the `"imports"` field
43-
directly.
44-
4538
One interesting requirement for `imports` is that they _must_ start with the `#`
4639
character to disambiguate from other imports. This is a bit annoying, but it's
4740
something that's not difficult to get used to. They also _must not_ start with
@@ -50,19 +43,14 @@ again it's just a matter of familiarity. So it's no big deal.
5043

5144
## Decision
5245

53-
We're going to configure `"imports"` in the `package.json` and `paths` in the
54-
`tsconfig.json` to use path aliases for imports.
46+
We're going to configure `"imports"` in the `package.json` to use path aliases for imports.
5547

5648
We'll set it to `"#*": "./*"` which will allow us to import anything in the root
5749
of the repo with `#<dirname>/<filepath>`.
5850

5951
## Consequences
6052

6153
This is unfortunately _very_ soon after making the decision to drop the alias.
62-
But I see this as slightly different because we're only using the alias to make
63-
up for a shortcoming in TypeScript temporarily. Once TypeScript supports the
64-
`"imports"` field, we can drop the `paths` field and just use the `"imports"`
65-
standard for Node.js.
6654

6755
If someone wants to use the Epic Stack without Node.js, and their runtime
6856
doesn't support `package.json` imports (I'm not sure whether other runtimes do

tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
"types": ["@react-router/node", "vite/client"],
77
"rootDirs": [".", "./.react-router/types"],
88
"paths": {
9-
"#app/*": ["./app/*"],
10-
"#tests/*": ["./tests/*"],
119
"@/icon-name": [
1210
"./app/components/ui/icons/types.ts",
1311
"./types/icon-name.d.ts"

0 commit comments

Comments
 (0)