You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
css-modules-kit uses paths to resolve import specifiers.
However, there are several edge cases that fail to resolve.
Case 1
One of these is Go to Definition in ts-plugin. Go to Definition fails if user clicks on import specifier with paths.
2025-03-01.18.32.25.mov
Case 2
Another is when the type definition file generated by codegen is type-checked by tsc.
// src/a.module.css
@import'@/d.module.css';
// src/d.module.css
.d_1 { color: red; }
// generated/a.module.css.d.ts// @ts-nocheckdeclareconststyles={
...(awaitimport('@/src/d.module.css')).default,// ^^^^^^^^^^^^^^^^^^// This import speficier cannot be resolved by tsc.// Therefore, the `(await import(...)) .default)` will be `any` type.// Worse, `styles` will also be of `any` type.};exportdefaultstyles;
Since styles will be any type, a type error will not be reported if you reference a non-existent class name from *.ts.
// src/a.tsimportstylesfrom'./a.module.css';styles.unknown;// This should be reported as a type error
$ npx tsc
$ echo$?0
Additional Information
The problem appears to be due to the following TypeScript behavior.
mizdra
changed the title
Cannot resolve *.module.css using paths of tsconfig.json
Cannot resolve *.module.css using paths of tsconfig.json or imports of package.json
Mar 1, 2025
mizdra
changed the title
Cannot resolve *.module.css using paths of tsconfig.json or imports of package.json
Cannot resolve *.module.css using paths of tsconfig.json
Mar 1, 2025
css-modules-kit uses
paths
to resolve import specifiers.However, there are several edge cases that fail to resolve.
Case 1
One of these is Go to Definition in ts-plugin. Go to Definition fails if user clicks on import specifier with
paths
.2025-03-01.18.32.25.mov
Case 2
Another is when the type definition file generated by codegen is type-checked by
tsc
.Since
styles
will be any type, a type error will not be reported if you reference a non-existent class name from*.ts
.Additional Information
The problem appears to be due to the following TypeScript behavior.
The text was updated successfully, but these errors were encountered: