microsoft / microsoft/TypeScript
TS 5.6 requires composite projects with noEmit to have fully accessible types, unlike 5.5
@sheetalkamat arbeitet bereits daran.
Seit 13.9.2024.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔎 Search Terms
TS2742, TS7056, TS9006, TS4058, TS4023, noEmit, composite, 5.6
🕗 Version & Regression Information
- This changed between versions 5.5.4 and 5.6.2
⏯ Playground Link
https://github.com/Ambroos/ts-56-composite-project-noemit
💻 Code
file: Internal.ts
interface Internal {
a: boolean,
}
export default function somethingInternal() {
return {
one: { a: true } as Internal,
};
}
file: index.ts
import createInternal from "./Internal";
export const one = createInternal().one;
file: tsconfig.json
{
"compilerOptions": {
"composite": true,
"noEmit": true,
"strict": true,
},
"include": [
"*.ts"
]
}
🙁 Actual behavior
In TS 5.6.2, run tsc and get error:
index.ts:3:14 - error TS4023: Exported variable 'one' has or is using name 'Internal' from external module "/Users/ambroos/Dev/ts-composite-5.6/Internal" but cannot be named.
3 export const one = createInternal().one;
This is the error in the sample project linked above (or created with the files from the code part). In our actual repo a large amount of new errors appeared that are related: TS2742, TS7056, TS9006, TS4058, TS4023.
🙂 Expected behavior
No errors, like 5.5.4 and older.
Additional information about the issue
This only happens in composite projects, even when not using --build. We have a large composite project, but the oldest parts of our code live in projects that don't emit since no-one is allowed to depend on them (they're apps that get built as-is).
In the past, when not emitting type declarations, it was OK to reference types that cannot be named, even in incremental compilation / composite projects. Now however it looks like because .tsbuildinfo is always generated, making code able to be emitted seems to have become required.
Maybe this is intentional, but it would be nice to still have some escape hatch for these types of composite project parts that don't actually need to emit declarations, they just need to be checked and transpiled.
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.