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

FEI-4957.7: Generate .js.flow files from .d.ts files #529

Merged
merged 2 commits into from
Feb 16, 2023
Merged

Conversation

kevinbarabash
Copy link
Contributor

Summary:

We want to generate .js.flow files from our .d.ts files so that wonder-stuff packages can be used in codebases that are still using Flow. This PR adds a build script to run flowgen on each .d.ts file in the dist folder of each package.

It also adds a script for removing .d.ts files that were generated from .test.ts files. Both scripts are written in TypeScript and use swc-node/register to run. I've added package.json scripts to make this easier. I'll research this further to see if there's a nice shebang approach we can use in the future, but this should suffice for now.

Issue: FEI-4957

Test plan:

  • yarn clean
  • yarn build:types
  • yarn build:flowtypes
  • See that .d.ts and .js.flow files have been added to each packages' dist folder
  • See that there are no tests folders in the dist folder
  • Copy the dist folders for wonder-stuff-core and wonder-stuff-testing into the node_modules folder of wonder-blocks
  • Restart flow in wonder-blocks, see that there are two Flow errors in wonder-blocks-icon (this is expected since the Flow types generated from the .d.ts files are different from the Flow types in the original code)

@kevinbarabash kevinbarabash self-assigned this Feb 15, 2023
@changeset-bot
Copy link

changeset-bot bot commented Feb 15, 2023

🦋 Changeset detected

Latest commit: 42c88ea

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@khanacademy/wonder-stuff-server-google Patch
@khanacademy/wonder-stuff-testing Patch
@khanacademy/wonder-stuff-sentry Patch
@khanacademy/wonder-stuff-server Patch
@khanacademy/wonder-stuff-core Patch
@khanacademy/wonder-stuff-i18n Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kevinbarabash kevinbarabash requested a review from a team February 15, 2023 19:14
@khan-actions-bot khan-actions-bot requested a review from a team February 15, 2023 19:14
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Feb 15, 2023

Gerald

Required Reviewers
  • @Khan/frontend-infra for changes to package.json, yarn.lock, .changeset/modern-turtles-invent.md, build-scripts/gen-flow-types.ts, build-scripts/remove-test-types-from-dist.ts, .github/workflows/node-ci.yml

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 15, 2023

Size Change: 0 B

Total Size: 4.36 kB

ℹ️ View Unchanged
Filename Size
packages/wonder-stuff-core/dist/es/index.browser.js 1.72 kB
packages/wonder-stuff-sentry/dist/es/index.browser.js 1.66 kB
packages/wonder-stuff-testing/dist/es/index.browser.js 976 B

compressed-size-action

@codecov
Copy link

codecov bot commented Feb 15, 2023

Codecov Report

Merging #529 (29374c8) into main (da34455) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 29374c8 differs from pull request most recent head 42c88ea. Consider uploading reports for the commit 42c88ea to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #529   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           59        59           
  Lines          845       843    -2     
  Branches       233       224    -9     
=========================================
- Hits           845       843    -2     
Impacted Files Coverage Δ
...ackages/wonder-stuff-sentry/src/kind-error-data.ts 100.00% <ø> (ø)
packages/wonder-stuff-server/src/start-server.ts 100.00% <ø> (ø)
...uff-server-google/src/add-app-engine-middleware.ts 100.00% <100.00%> (ø)
packages/wonder-stuff-core/src/kind-error.ts 100.00% <0.00%> (ø)
...ges/wonder-stuff-server-google/src/start-server.ts 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da34455...42c88ea. Read the comment docs.

Copy link
Member

@jeresig jeresig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! I bet we'll want to use that gen-flow-types.ts in wonder-blocks and perseus, too!

const command = `yarn flowgen ${inFile} -o ${outFile} --add-flow-header`;

try {
execSync(command, {cwd: rootDir});

Check warning

Code scanning / CodeQL

Shell command built from environment values

This shell command depends on an uncontrolled [file name](1).
@kevinbarabash kevinbarabash merged commit 035e345 into main Feb 16, 2023
@kevinbarabash kevinbarabash deleted the fei-4957.7 branch February 16, 2023 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants