Skip to content

Commit 7071388

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

File tree

9 files changed

+13
-27
lines changed

9 files changed

+13
-27
lines changed

app/components/error-boundary.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
useParams,
77
useRouteError,
88
} from 'react-router'
9-
import { getErrorMessage } from '#app/utils/misc'
9+
import { getErrorMessage } from '#app/utils/misc.tsx'
1010

1111
type StatusHandler = (info: {
1212
error: ErrorResponse

app/routes/admin+/cache.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
useSearchParams,
99
useSubmit,
1010
} from 'react-router'
11-
import { GeneralErrorBoundary } from '#app/components/error-boundary'
11+
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
1212
import { Field } from '#app/components/forms.tsx'
1313
import { Spacer } from '#app/components/spacer.tsx'
1414
import { Button } from '#app/components/ui/button.tsx'

app/routes/admin+/cache_.sqlite.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { cache } from '#app/utils/cache.server.ts'
44
import {
55
getInstanceInfo,
66
getInternalInstanceDomain,
7-
} from '#app/utils/litefs.server'
7+
} from '#app/utils/litefs.server.ts'
88
import { type Route } from './+types/cache_.sqlite.ts'
99

1010
export async function updatePrimaryCacheValue({

app/utils/auth.server.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { http, HttpResponse } from 'msw'
22
import { describe, expect, test } from 'vitest'
3-
import { server } from '#tests/mocks'
3+
import { server } from '#tests/mocks/index.ts'
44
import { consoleWarn } from '#tests/setup/setup-test-env.ts'
55
import { checkIsCommonPassword, getPasswordHashParts } from './auth.server.ts'
66

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

prisma/seed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { faker } from '@faker-js/faker'
22
import { prisma } from '#app/utils/db.server.ts'
3-
import { MOCK_CODE_GITHUB } from '#app/utils/providers/constants'
3+
import { MOCK_CODE_GITHUB } from '#app/utils/providers/constants.ts'
44
import {
55
createPassword,
66
createUser,

tests/e2e/onboarding.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { prisma } from '#app/utils/db.server.ts'
44
import {
55
normalizeEmail,
66
normalizeUsername,
7-
} from '#app/utils/providers/provider'
7+
} from '#app/utils/providers/provider.ts'
88
import {
99
USERNAME_MAX_LENGTH,
1010
USERNAME_MIN_LENGTH,
11-
} from '#app/utils/user-validation'
11+
} from '#app/utils/user-validation.ts'
1212
import { readEmail } from '#tests/mocks/utils.ts'
1313
import { createUser, expect, test as base } from '#tests/playwright-utils.ts'
1414

tests/playwright-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
sessionKey,
88
} from '#app/utils/auth.server.ts'
99
import { prisma } from '#app/utils/db.server.ts'
10-
import { MOCK_CODE_GITHUB_HEADER } from '#app/utils/providers/constants.js'
11-
import { normalizeEmail } from '#app/utils/providers/provider.js'
10+
import { MOCK_CODE_GITHUB_HEADER } from '#app/utils/providers/constants.ts'
11+
import { normalizeEmail } from '#app/utils/providers/provider.ts'
1212
import { authSessionStorage } from '#app/utils/session.server.ts'
1313
import { createUser } from './db-utils.ts'
1414
import {

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)