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

fix: add missing TSInferType node #68

Merged
merged 3 commits into from
Jan 1, 2019
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
1 change: 1 addition & 0 deletions src/ast-node-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const AST_NODE_TYPES: { [key: string]: string } = {
TSExportAssignment: 'TSExportAssignment',
TSExportKeyword: 'TSExportKeyword',
TSImportType: 'TSImportType',
TSInferType: 'TSInferType',
TSLiteralType: 'TSLiteralType',
TSIndexedAccessType: 'TSIndexedAccessType',
TSIndexSignature: 'TSIndexSignature',
Expand Down
8 changes: 7 additions & 1 deletion src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2690,7 +2690,13 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
});
break;
}

case SyntaxKind.InferType: {
Object.assign(result, {
type: AST_NODE_TYPES.TSInferType,
typeParameter: convertChildType(node.typeParameter)
});
break;
}
default:
deeplyCopy();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type Unpacked<T> =
T extends (infer U)[] ? U :
T extends infer U ? U :
T extends Promise<infer U> ? U :
T;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Foo<T> = T extends { a: infer U, b: infer U } ? U : never;
1 change: 1 addition & 0 deletions tests/fixtures/typescript/types/conditional-infer.src.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Element<T> = T extends (infer U)[] ? U : T;
6 changes: 6 additions & 0 deletions tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1884,6 +1884,12 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" en

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

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

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"`;

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"`;

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"`;

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