-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Should deno support "declare module"? #15132
Comments
I don't think so. For that scenario the way to do it is to use |
Correct. We do not generally support ambient module declarations, as the break the model of tightly coupling code to types. That being said, there is already limited support, discussed further down in manual at: https://deno.land/manual/typescript/types#using-ambient-or-global-types |
Thanks. I will try to find how I was hitting the querystring.d.ts and how to avoid it. |
In front-end development, it's common for frameworks to use files with non-standard extensions ( |
I tried the approaches mentioned in the docs but couldn't seem to get them to pass the type-checker. I couldn't get // grid.d.ts.
// Ambient module declaration cannot specify relative module name.deno-ts(2436)
declare module './grid.svg' {
const text: string
export default text
} // Some TypeScript file with the import.
import gridURI from './grid.svg'
declare module './grid.svg' {
const text: string
// Exports and export assignments are not permitted in module augmentations.deno-ts(2666)
export default text
} Neither I am currently using a gnarly async import with a cast like: const gridURI = (<{ default: string }> await import('./grid.svg')).default |
This also affects ambient imports provided by Sveltekit. Might affect #17248 |
For now, for every ambient imports in sveltekit, I have to create a random import map like the following to make it work, but doesn't seem like a good solution. {
"imports": {
"$env/static/private": "./.svelte-kit/ambient.d.ts"
}
} |
The following example illustrates what is missing
test.ts:
foo.d.ts:
$ npx tsc test.ts $ deno run --check=all --reload test.ts error: Relative import path "bar" not prefixed with / or ./ or ../ at file:///home/espindola/chisel/test-declare/test.ts:2:21
code like this is fund, for example, in https://esm.sh/v86/@types/node@16.11.33/querystring.d.ts
The text was updated successfully, but these errors were encountered: