Skip to content
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

declare module inside .d.ts does not get picked up by Deno #23007

Open
Mqxx opened this issue Mar 20, 2024 · 6 comments
Open

declare module inside .d.ts does not get picked up by Deno #23007

Mqxx opened this issue Mar 20, 2024 · 6 comments

Comments

@Mqxx
Copy link

Mqxx commented Mar 20, 2024

Hey, I currently have a problem when importing non js/ts files inside a js/ts file. deno-ts shows an error with non-resolvable imports for non-js/ts files.

For example i have this index.ts files, somewhere in my project:

import styles from './hello_world.scss'
//     ^
//     Error: Module '"hello_world.scss"' has no default export. deno-ts(1192)

This behavior is correct because scss does not have a valid default export.

However, if I now create an index.d.ts file in the root of my project with the following content, the error still occurs. Deno simply ignores this file.

declare module '*.scss';

or

declare module '*.scss' {
  const content: string;
  export default content;
}

Neither of the two contents work. Also adding the .d.ts file to the types array in the compilerOptions did not help.

It would be really great if this error could be fixed or if this could be added as a feature.

  • Deno version used: 1.41.3

Link to the discussion on discord.

@Mqxx
Copy link
Author

Mqxx commented Oct 7, 2024

#23319

@greentore
Copy link

There's also an older (closed) issue: #15132
Having to prefix fancy imports with @ts-types comments really sucks, but at least it works.

@strootje
Copy link

currently running on Deno 2.0.6. This is still an issue for me.

My two use cases are:

  • unocss, having to import virtual:uno.css.
  • imagetools, importing *.*&imagetools.

I used to just declare these in a custom types.d.ts. Now it's just errors :(

@Mqxx
Copy link
Author

Mqxx commented Nov 27, 2024

Still persistent in latest Deno version (v2.1.1)

@nounder
Copy link

nounder commented Dec 4, 2024

Same on 2.1.2. I wasted few hours trying to fix it today :(

@ije
Copy link
Contributor

ije commented Dec 29, 2024

some types from esm.sh are broken by the issue too.

declare module 'highlight.js/private' {
   // ...
}
declare module 'https://esm.sh/highlight.js@11.9.0/types/index.d.ts' {
    import { KeywordDict } from "highlight.js/private";
    // ...
}

error output:

error: Relative import path "highlight.js/private" not prefixed with / or ./ or ../

_

Deno 2.1.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants