Open
Description
Bug Report
π Search Terms
baseUrl rootDirs non-relative module .d.ts
π Version & Regression Information
- This is the behavior in every version I tried : 5.1.3 and 4.9.5.
β― Playground Link
Playground link with relevant code
π» Code
// tsconfig.json
{
"compilerOptions": {
"baseUrl": "./src",
"rootDirs": [".", "generated"],
}
}
// src/index.ts
import stylesA from "css/a.module.scss" // π Cannot find module 'css/a.module.scss' or its corresponding type declarations.ts(2307)
import stylesB from "./css/b.module.scss" // π
console.log(stylesA, stylesB)
// src/css/a.module.scss
.a {
color: red;
}
// src/css/b.module.scss
.b {
color: red;
}
// generated/src/css/a.module.scss.d.ts
export type Styles = {
'a': string;
};
declare const styles: Styles;
export default styles;
// generated/src/css/b.module.scss.d.ts
export type Styles = {
'b': string;
};
declare const styles: Styles;
export default styles;
π Actual behavior
On first import in index.ts
, the ".d.ts" file is not found: "Cannot find module 'css/a.module.scss' or its corresponding type declarations.ts(2307)"
On the second one, the ".d.ts" file is found and types are displayed correctly.
π Expected behavior
Whenever it's a non-relative import (thanks to the baseUrl
option) or a relative import, it should find the ".d.ts" file because of the rootDirs
settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment