Open KraXen72 opened 8 months ago
I think the documentation needs to be improved.
isn't globals just for declaring global variables one by one, or from enviroment sets? rather, i would need quick lint to recognize all the global types declared in app.d.ts and accept them as global
quick-lint-js currently does not have a mechanism to take global variables declared in one file (app.d.ts in your case) and make them visible in another file.
Some possible solutions:
import
instead of globals."globals-files"
feature in quick-lint-js.config to specify source files. You would list "globals-files": ["src/app.d.ts"]
. (This feature does not yet exist.)@KraXen72 Which solutions sound good to you?
while 1 is a good short term solution, i think 5 would be the best - scanning, relevant .d.ts files in the project (as far as i understand it, quicklint already does scanning and parsing in these files, since i get quicklint warnings in them), and parsing declare global blocks or other ways to declare global types, so quicklint recognizes global types and supresses the unknown type warning.
until this is implemented, a stopgap solution could be adding the option to disable the 'unknown type' warning, and leave known/unknown logic to the typescript LSP. I think many people use quicklint alongside the ts lsp, and not instead of it.
while importing and exporting types is likely a better way to manage types than globals, for a lot of projects i either don't have that many types (they fit in 1 file), or i don't want to put in the extra effort of import/export management for types too. yes, autoimport extensions exist and they do help, but i found they often make mistakes when modifying existing imports, or just refuse to create 'import type {}' imports.
as far as i understand it, quicklint already does scanning and parsing in these files, since i get quicklint warnings in them
quick-lint-js only reports diagnostics for files you open in your editor. quick-lint-js does not scan all files in your project automatically.
I did want to implement project-wide analysis, but only by following import
statements. Your use case suggests that I need to follow more than just import
statements. I'll keep this in consideration when designing the analysis.
a stopgap solution could be adding the option to disable the 'unknown type' warning, and leave known/unknown logic to the typescript LSP.
In the next few months, I don't plan on implementing a proper fix for this issue. If you want to avoid the warnings but continue using quick-lint-js, you can configure quick-lint-js.
for now, i'm using oxc linter, but i like quick-lint more - i'll try configuring it in a bit. thanks!
sveltekit projects have a
app.d.ts
file. i use it like this:However, the global types are not recognized and show:![image](https://github.com/quick-lint/quick-lint-js/assets/21956756/e0e3c3d5-d2d7-4465-8a36-4ddea070d46e)
tsconfig:
the "./.svelte-kit/tsconfig.json" is auto-generated / changes a lot, better to check a bare sveltekit starter project.