microsoft / microsoft/TypeScript
Cannot use ".d.ts" file on non-relative import with `rootDirs` and `baseUrl`
Offen
@weswigham arbeitet bereits daran.
Seit 23.6.2023.
Needs Investigation
Rescheduled
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.