microsoft / microsoft/TypeScript
[isolatedDeclarations] Should imported JSON files be emitted when "resolveJsonModules", "emitDeclarationOnly", and "isolatedDeclarations" are all enabled?
@sheetalkamat is already working on this.
Since Jun 18, 2024.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔍 Search Terms
json, resolvejsonmodules, isolateddeclarations, emit, declarations, import, emitDeclarationOnly
✅ Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
Emit/transpile JSON files when the aforementioned compile options are enabled
📃 Motivating Example
The primary purpose of isolated declarations is to be able to emit declarations for a project without needing to typecheck it and one of the main motivators for that is being able to start typechecking downstream projects, e.g. in a composite build, without waiting for typecheck.
It might be fair to say then that it would be good for downstream projects to be able to start typechecking without waiting for their dependees to transpile code. Even with isolated declarations, this is not possible at the moment, because types may depend on JSON files when resolveJsonModules is enabled, and JSON files are only emitted/copied when JS transpilation is enabled, i.e. "emitDeclarationOnly": false.
💻 Use Cases
Being able to typecheck a composite project in parallel where sub-projects are configured with
"isolatedDeclarations": true,
"emitDeclarationOnly": true,
"resolveJsonModule": true,
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.