Skip to content

Commit

Permalink
Remove 'mixins' from .js.flow output (#549)
Browse files Browse the repository at this point in the history
## Summary:
Some of the files flowgen was generated were using 'mixins' instead of 'extends'. This PR fixes this by post-processing the files.

Issue: None

## Test plan:
- yarn build:types
- yarn build:flowtypes
- search for 'mixins' in the dist/ folders, see that it no longer appears there

Author: kevinbarabash

Reviewers: jeresig

Required Reviewers:

Approved By: jeresig

Checks: ⌛ Test (macos-latest, 16.x), ✅ CodeQL, ✅ Lint, typecheck, and coverage check (ubuntu-latest, 16.x), ⏭  dependabot, ✅ gerald, ✅ Analyze (javascript), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 16.x)

Pull Request URL: #549
  • Loading branch information
kevinbarabash authored Feb 27, 2023
1 parent 9d1063f commit cfadf15
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/quick-keys-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/wonder-stuff-core": patch
"@khanacademy/wonder-stuff-sentry": patch
---

Update generate flow types to use 'extends' instead of 'mixins'
13 changes: 13 additions & 0 deletions build-scripts/gen-flow-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {execFileSync} from "child_process";
import * as fs from "fs";
import * as path from "path";
import * as fglob from "fast-glob";

Expand All @@ -14,6 +15,18 @@ for (const inFile of files) {
try {
execFileSync("yarn", args, {cwd: rootDir});
console.log(`✅ wrote: ${outFile}`);

// `flowgen` sometimes outputs code that uses `mixins` instead of `extends`
// so we do some post-processing on the files to clean that up.
const contents = fs.readFileSync(path.join(rootDir, outFile), "utf-8");
if (contents.includes(" mixins ")) {
console.log("replacing 'mixins' with 'extends'");
fs.writeFileSync(
path.join(rootDir, outFile),
contents.replace(/ mixins /g, " extends "),
"utf-8",
);
}
} catch (e) {
console.log(`❌ error processing: ${inFile}: ${e}`);
}
Expand Down

0 comments on commit cfadf15

Please sign in to comment.