Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,20 @@ if(!((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
}`;
assert.doesNotThrow(() => transformSync(source));
});

test("should handle advanced type-level constructs", (t) => {
const inputCode = `
type Fn = (x: string) => number;

type ReturnType<T> = T extends (...args: any) => infer R ? R : never;

type X = ReturnType<Fn>;

type Props = { id: string; name: string };
type Keys = keyof Props;

type A = typeof Math;
`;
const { code } = transformSync(inputCode);
t.assert.snapshot(code);
});
4 changes: 4 additions & 0 deletions test/snapshots/index.test.js.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ exports[`should handle User type and isAdult function 1`] = `
"\\n \\n \\n \\n \\n\\n function isAdult(user ) {\\n return user.age >= 18;\\n }\\n "
`;

exports[`should handle advanced type-level constructs 1`] = `
"\\n\\t\\t \\n\\n\\t\\t \\n\\n\\t\\t \\n\\n\\t\\t \\n\\t\\t \\n\\n\\t\\t \\n\\t"
`;

exports[`should handle class modifiers 1`] = `
"\\n\\t\\tclass PrivateConstructor {\\n\\t\\t constructor() {}\\n\\t\\t a() {}\\n\\t\\t b() {}\\n\\t\\t static create() {\\n\\t\\t return new PrivateConstructor()\\n\\t\\t }\\n\\t\\t}\\n\\n\\t\\tconst ins = PrivateConstructor.create()\\n\\t\\tconsole.log(ins)\\n\\t"
`;
Expand Down