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
Alias is not resolved #468
Comments
You'll also have to configure the alias for typescript though tsconfig/jsconfig.json https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping |
That error is because we have used some special property injected by svelte2tsx to do component type-check. If we can't find the actual file we can't transform the file using svelte2tsx. @cayter where do you put your tsconfig? |
@jasonlyu123 Below is my project folder structure which happens to be a monorepo for both backend/frontend: .
├── Makefile
├── README.md
├── database
│ └── database.rules.json
├── firebase.json
├── firestore
│ ├── firestore.indexes.json
│ └── firestore.rules
├── functions // backend code
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ └── index.ts
│ └── tsconfig.json
├── hosting // frontend PWA code
│ ├── ...
│ ├── src
│ │ ├── components
│ │ │ ├── App.svelte
│ │ │ └── ...
│ │ ├── images
│ │ │ ├── cover.png
│ │ │ └── ...
│ │ ├── index.css
│ │ ├── index.ts
│ │ ├── pages
│ │ │ ├── Auth
│ │ │ │ └── ...
│ │ │ ├── Error
│ │ │ │ └── ...
│ │ │ ├── Home
│ │ │ │ └── ...
│ │ │ └── User
│ │ │ └── ...
│ │ └── stores
│ │ └── ...
│ ├── svelte.config.js
│ ├── tailwind.config.js
│ ├── tsconfig.json
│ ├── vite.config.ts
│ └── workbox.config.js
├── package-lock.json
└── package.json hosting/tsconfig.json {
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": "src",
"declaration": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"importsNotUsedAsValues": "error",
"isolatedModules": true,
"lib": ["dom", "esnext", "es6"],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"rootDir": "src",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"strictBindCallApply": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictNullChecks": true,
"target": "esnext",
"types": ["jest", "node", "svelte"],
"paths": {
"/@/*": ["*"]
}
},
"include": ["src/**/*"],
"exclude": ["node_modules/*", "public/*"]
} |
Yep, this is relevant to alias path resolving defined in the project's |
Can you check the output channel of vscode, chose svelte in the dropdown on the right. And see if you have something like this |
I can reproduce this. For some reason |
The problem is inside our |
If a path alias starts with "/", it is recognized as an absolute path by the paths library. Therefore virtual svelte files with such paths were resolved with the normal tsSys. This fix adds an additional check for the path aliases. sveltejs#468
OP actually said it works with |
If a path alias starts with "/", it is recognized as an absolute path by the paths library. Therefore virtual svelte files with such paths were resolved with the normal tsSys. This fix adds an additional check for the path aliases. #468
I forgot to say how awesome you guys are. Thank you for quick response |
Describe the bug
I used import alias
@/
and it worked. Then i switched to Vite and it supports only root aliases. So i switched my code to use/@/
aliases. It compiles and works in browser, but gives me an error in vscode:To Reproduce
Use
/@/
importExpected behavior
Everything works
System (please complete the following information):
The text was updated successfully, but these errors were encountered: