Skip to content
This repository was archived by the owner on Jan 14, 2019. It is now read-only.

Commit 5a1a5ca

Browse files
armano2JamesHenry
authored andcommitted
fix: add missing TSInferType node (#68)
1 parent 36d2681 commit 5a1a5ca

7 files changed

+2713
-1
lines changed

src/ast-node-types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export const AST_NODE_TYPES: { [key: string]: string } = {
115115
TSExportAssignment: 'TSExportAssignment',
116116
TSExportKeyword: 'TSExportKeyword',
117117
TSImportType: 'TSImportType',
118+
TSInferType: 'TSInferType',
118119
TSLiteralType: 'TSLiteralType',
119120
TSIndexedAccessType: 'TSIndexedAccessType',
120121
TSIndexSignature: 'TSIndexSignature',

src/convert.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -2690,7 +2690,13 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
26902690
});
26912691
break;
26922692
}
2693-
2693+
case SyntaxKind.InferType: {
2694+
Object.assign(result, {
2695+
type: AST_NODE_TYPES.TSInferType,
2696+
typeParameter: convertChildType(node.typeParameter)
2697+
});
2698+
break;
2699+
}
26942700
default:
26952701
deeplyCopy();
26962702
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type Unpacked<T> =
2+
T extends (infer U)[] ? U :
3+
T extends infer U ? U :
4+
T extends Promise<infer U> ? U :
5+
T;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Foo<T> = T extends { a: infer U, b: infer U } ? U : never;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Element<T> = T extends (infer U)[] ? U : T;

tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap

+6
Original file line numberDiff line numberDiff line change
@@ -1884,6 +1884,12 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" en
18841884

18851885
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/types/conditional.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
18861886

1887+
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/types/conditional-infer.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
1888+
1889+
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/types/conditional-infer-nested.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
1890+
1891+
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/types/conditional-infer-simple.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
1892+
18871893
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/types/conditional-with-null.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
18881894

18891895
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/types/indexed.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

0 commit comments

Comments
 (0)