Skip to content

Commit

Permalink
chore: tsconfig paths for test - TS2307 Cannot find module in IDE (#550)
Browse files Browse the repository at this point in the history
# Motivation

Don't know for VS Code but, Webstorm has issue resolving `*.svelte`
component when the import used `$lib/`. It seems it cannot inherits the
`path` defined in `"./.svelte-kit/tsconfig.json"` despite the extension
of the configs. I would guess the issue is related to Webstorm having
issue resolving relative paths.

# Changes

- Add `paths` to `tsconfig.spec.json`.

# Error

> TS2307: Cannot find module $lib/ components/ Back. svelte or its
corresponding type declarations.

<img width="1470" alt="Capture d’écran 2024-12-10 à 08 41 02"
src="https://github.com/user-attachments/assets/6ce4167e-650c-444f-8106-390761ab4db2">
  • Loading branch information
peterpeterparker authored Dec 10, 2024
1 parent 1cd00a2 commit 3bfceef
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"types": ["vitest/globals"]
"types": ["vitest/globals"],
"paths": {
"$docs": ["./src/docs"],
"$docs/*": ["./src/docs/*"],
"$lib": ["./src/lib"],
"$lib/*": ["./src/lib/*"]
}
},
"exclude": [],
"include": [
Expand Down

0 comments on commit 3bfceef

Please sign in to comment.