Uh oh!
There was an error while loading. Please reload this page.
Add auto-generation of TypeScript definitions on build - #38990
Conversation
facebook-github-bot
commented
Aug 14, 2023
This pull request was exported from Phabricator. Differential Revision: D48312463 |
Base commit: e44fdfe |
facebook-github-bot
commented
Aug 14, 2023
This pull request was exported from Phabricator. Differential Revision: D48312463 |
facebook-github-bot
commented
Aug 14, 2023
This pull request was exported from Phabricator. Differential Revision: D48312463 |
facebook-github-bot
commented
Aug 14, 2023
This pull request was exported from Phabricator. Differential Revision: D48312463 |
facebook-github-bot
commented
Aug 14, 2023
This pull request was exported from Phabricator. Differential Revision: D48312463 |
facebook-github-bot
commented
Aug 14, 2023
This pull request was exported from Phabricator. Differential Revision: D48312463 |
facebook-github-bot
commented
Aug 14, 2023
This pull request was exported from Phabricator. Differential Revision: D48312463 |
Summary: Pull Request resolved: #38990 This PR adds auto-generation of Typescript definitions from Flow source code for packages using the shared monorepo build setup (#38718). Today, these are the following Node.js packages: - `packages/community-cli-plugin` - `packages/dev-middleware` (⬅️ `emitTypeScriptDefs` enabled) This also improves emitted Flow definitions (`.js.flow`), by using [`flow-api-translator`](https://www.npmjs.com/package/flow-api-translator) to strip implementations. **All changes** - Include `flow-api-translator` and configure this to emit type definitions as part of `yarn build`. - Add translation from Flow source to TypeScript definitions (`.d.ts`) adjacent to each built file. - Improve emitted Flow definitions (`.js.flow`), by using `flow-api-translator` to strip implementations (previously, source files were copied). The Flow and TS defs now mirror each other. - Add `emitFlowDefs` and `emitTypeScriptDefs` options to build config to configure the above. - Integrate TypeScript compiler to perform program validation on emitted `.d.ts` files. - This is based on this guide: https://github.com/microsoft/TypeScript-wiki/blob/main/Using-the-Compiler-API.md#a-minimal-compiler. - Throw an exception on the `rewritePackageExports` step if a package does not define an `"exports"` field. - Add minimal `flow-typed` definitions for `typescript` 😄. **Notes on [`flow-api-translator`](https://www.npmjs.com/package/flow-api-translator)** This project is experimental but is in a more mature state than when we evaluated it earlier in 2023. - It's now possible to run this tool on our new Node.js packages, since they are exclusively authored using `import`/`export` syntax (a requirement of the tool). - As a safety net, we run the TypeScript compiler against the generated program, which will fail the build. Changelog: [Internal] Reviewed By: robhogan Differential Revision: D48312463 fbshipit-source-id: 5ac8f3b054c313407c37dca060e0c5e77d112e9a
facebook-github-bot
commented
Aug 14, 2023
This pull request was exported from Phabricator. Differential Revision: D48312463 |
facebook-github-bot
commented
Aug 14, 2023
This pull request has been merged in a978d34. |
Summary:
This PR adds auto-generation of Typescript definitions from Flow source code for packages using the shared monorepo build setup (#38718).
Today, these are the following Node.js packages:
packages/community-cli-pluginpackages/dev-middleware(⬅️emitTypeScriptDefsenabled)This also improves emitted Flow definitions (
.js.flow), by usingflow-api-translatorto strip implementations.All changes
flow-api-translatorand configure this to emit type definitions as part ofyarn build..d.ts) adjacent to each built file..js.flow), by usingflow-api-translatorto strip implementations (previously, source files were copied). The Flow and TS defs now mirror each other.emitFlowDefsandemitTypeScriptDefsoptions to build config to configure the above..d.tsfiles.rewritePackageExportsstep if a package does not define an"exports"field.flow-typeddefinitions fortypescript😄.Notes on
flow-api-translatorThis project is experimental but is in a more mature state than when we evaluated it earlier in 2023.
import/exportsyntax (a requirement of the tool).Changelog: [Internal]
Differential Revision: D48312463