Skip to content

Commit 150508f

Browse files
feat: add TypeScript helpers (#566)
* create ast.ts * handle annotations for more node types and add class props helpers * refactoring * refactoring and adding methods back * adding tests * implement Oliver's suggestions * update functions tests * add class tests * wrap node in class if it's a method * add methods tests, unnest tests * add isUnionOf and isIntersectionOf * add more methods, fix bug in hasReturnAnnotation * add getParameters tests and initial annotation tests [skip ci] * refactor: nitpicks and formatting * refactor: use optional chaining * refactor: use helper function to simplify hasTypeProp * feat: make Explorer available in tests * fix: use environment specific loader for dynamic imports * chore: ignore eslint * Apply suggestions from code review Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * fix errors, remove isUnionOf and isIntersectionOf * rename find<Nodes> to get<Nodes> * refactor: use setup file for slow task (webpack) * test matches with empty trees * refactor: remove type casts from getAll * refactor: simplify types Mostly by using TS's built in type predicates --------- Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
1 parent 520a3b4 commit 150508f

File tree

8 files changed

+1764
-66
lines changed

8 files changed

+1764
-66
lines changed

packages/helpers/lib/class/explorer.ts

Lines changed: 561 additions & 0 deletions
Large diffs are not rendered by default.

packages/helpers/lib/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { strip } from "./strip";
22
import astHelpers from "../python/py_helpers.py";
33

4+
export const Explorer = async (code: string) =>
5+
new (await import("./class/explorer")).Explorer(code);
6+
47
declare global {
58
var IS_REACT_ACT_ENVIRONMENT: boolean;
69
}

packages/shared/tooling/webpack-compile.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const __dirname = new URL(".", import.meta.url).pathname;
66

77
const FIXTURES_DIR = path.join(__dirname, "../../../__fixtures__/dist");
88

9-
export const compileForTests = () => {
9+
const compileForTests = () => {
1010
// It's necessary to manually remove the previous build artifacts so we can
1111
// check that the build is successful. This should not be necessary, but
1212
// webpack can fail silently.
@@ -17,7 +17,19 @@ export const compileForTests = () => {
1717
const result = spawnSync(
1818
"webpack",
1919
// We only need the test-runner to be compiled for testing.
20-
["--color", "--env", "development", "--config-name", "test-runner"],
20+
[
21+
"--color",
22+
"--env",
23+
"development",
24+
"--config-name",
25+
"test-runner-index",
26+
"--config-name",
27+
"test-runner-dom-test-evaluator",
28+
"--config-name",
29+
"test-runner-javascript-test-evaluator",
30+
"--config-name",
31+
"test-runner-python-test-evaluator",
32+
],
2133
{
2234
encoding: "utf8",
2335
},
@@ -37,3 +49,5 @@ export const compileForTests = () => {
3749
console.error(result.stderr);
3850
}
3951
};
52+
53+
compileForTests();

0 commit comments

Comments
 (0)