Open ZhengXiaowei opened 1 year ago
Hi @ZhengXiaowei, this may be a naive thing to suggest (I'm not really in the world of JavaScript / TypeScript), but I added a tsconfig.json
file and told it to look for everything *.ts
-related, and it was able to find the global definitions.
Hi @ZhengXiaowei, this may be a naive thing to suggest (I'm not really in the world of JavaScript / TypeScript), but I added a
tsconfig.json
file and told it to look for everything*.ts
-related, and it was able to find the global definitions.
I configured it to tsconfig.json
but it's still not working.😭
I dont think you should have to, but did you try restarting the language server (command palette > editor: restart language server
) to see if it picked up the changes? Can you include an image of the project tree?
I retry it today, and it's work for the typescript project, but it's doesn't work for the vue-typescript project. it's my project tree:
Hi @JosephTLyons, can this issue be fixed?
This is related to, and extends to declaring modules for custom file type recognition. the TS LS implementation doesn't seem to pick up on this. Consider a declarations.ts
file:
declare module '*.graphql' {
const GraphQL: string;
// @ts-ignore
export = GraphQL;
}
declare module '*.yml' {
const Yaml: string;
// @ts-ignore
export = Yaml;
}
This provides instruction to TS that .graphql
files and .yml
files can be resolved when imported via e.g. import typeDefs from './mutations.graphql';
I've not been able to get Zed to recognize these imports as resolvable, and TS will always present an error that they cannot be resolved.
I dont think you should have to, but did you try restarting the language server (command palette >
editor: restart language server
) to see if it picked up the changes? Can you include an image of the project tree?
Your method works! But I have a question, why does the language server crash after a while?
I am using TypeScript + Vue now. Whenever I immerse myself in editing Vue files, the language server crashes after a while.
Before you gave this solution, I usually forced Zed to close by CMD+Q
and reopen it to solve it.
Although your method works, it is too inefficient. Our users cannot always restart the language server frequently. I think Zed did something to cause the TypeScript and Vue language servers to crash and exit. Can we do it like VS Code, automatically restart after detecting the language server crash instead of telling the user nothing.
Check for existing issues
Describe the feature
Unable to recognize the types and methods defined in global.d.ts.
I have a
global.d.ts
file in the src directory, but when writing code in*.ts
files, I cannot access the types and methods defined inglobal.d.ts
.e.g:
If applicable, add mockups / screenshots to help present your vision of the feature
No response