Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[heft] Add .d.ts shims for secondary module kinds #3539

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dmichon-msft
Copy link
Contributor

@dmichon-msft dmichon-msft commented Jul 14, 2022

Summary

Modifies the multi-emit logic for the Heft TypeScript plugin to generate .d.ts shim files for non-primary output kinds, that redirect to the primary .d.ts files.

Details

Creates shim files containing:

export * from '../path/to/declaration';
// If a default export exists
export { default as default } from '../path/to/declaration';

The motivation is to better support separation of transpilation and type-checking by having the transpilation step emit .d.ts stubs that can be trivially generated from the source files in an isolated per-module fashion, which at generation time may point to a declaration file that does not yet exist. The real declaration files would be generated later, during type-checking, so that downstream packages can still type-check correctly, even with deep imports.

How it was tested

Enabled multi-emit and isolatedModules in the node rig temporarily. Verified output content.

@dmichon-msft
Copy link
Contributor Author

I'm not entirely happy with how the opt-in currently works. I expect it may be best to have an express option in the moduleKindsToEmit collection to emit the shim.

@iclanton iclanton added this to In Progress in Bug Triage Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Bug Triage
  
In Progress
Development

Successfully merging this pull request may close these issues.

None yet

1 participant