Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6ff919
commit 59d24a4
Showing
17 changed files
with
1,637 additions
and
6 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/babel-generator/test/fixtures/typescript/infer-with-constraints/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type X3<T> = T extends [infer U extends number] ? MustBeNumber<U> : never; | ||
type X4<T> = T extends [infer U extends number, infer U extends number] ? MustBeNumber<U> : never; | ||
type X5<T> = T extends [infer U extends number, infer U] ? MustBeNumber<U> : never; | ||
type X6<T> = T extends [infer U, infer U extends number] ? MustBeNumber<U> : never; | ||
type X7<T> = T extends [infer U extends string, infer U extends number] ? U : never; |
5 changes: 5 additions & 0 deletions
5
packages/babel-generator/test/fixtures/typescript/infer-with-constraints/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type X3<T> = T extends [infer U extends number] ? MustBeNumber<U> : never; | ||
type X4<T> = T extends [infer U extends number, infer U extends number] ? MustBeNumber<U> : never; | ||
type X5<T> = T extends [infer U extends number, infer U] ? MustBeNumber<U> : never; | ||
type X6<T> = T extends [infer U, infer U extends number] ? MustBeNumber<U> : never; | ||
type X7<T> = T extends [infer U extends string, infer U extends number] ? U : never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...t/fixtures/typescript/types/infer-with-constraints-and-conditional-types-babel-7/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
type X<U, T> = T extends [infer U extends T ? U : T] ? U : T; |
3 changes: 3 additions & 0 deletions
3
...xtures/typescript/types/infer-with-constraints-and-conditional-types-babel-7/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"BABEL_8_BREAKING": false | ||
} |
115 changes: 115 additions & 0 deletions
115
...ixtures/typescript/types/infer-with-constraints-and-conditional-types-babel-7/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":61,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":61,"index":61}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":61,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":61,"index":61}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "TSTypeAliasDeclaration", | ||
"start":0,"end":61,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":61,"index":61}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":5,"end":6,"loc":{"start":{"line":1,"column":5,"index":5},"end":{"line":1,"column":6,"index":6},"identifierName":"X"}, | ||
"name": "X" | ||
}, | ||
"typeParameters": { | ||
"type": "TSTypeParameterDeclaration", | ||
"start":6,"end":12,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":12,"index":12}}, | ||
"params": [ | ||
{ | ||
"type": "TSTypeParameter", | ||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":8,"index":8}}, | ||
"name": "U" | ||
}, | ||
{ | ||
"type": "TSTypeParameter", | ||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":11,"index":11}}, | ||
"name": "T" | ||
} | ||
] | ||
}, | ||
"typeAnnotation": { | ||
"type": "TSConditionalType", | ||
"start":15,"end":60,"loc":{"start":{"line":1,"column":15,"index":15},"end":{"line":1,"column":60,"index":60}}, | ||
"checkType": { | ||
"type": "TSTypeReference", | ||
"start":15,"end":16,"loc":{"start":{"line":1,"column":15,"index":15},"end":{"line":1,"column":16,"index":16}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":15,"end":16,"loc":{"start":{"line":1,"column":15,"index":15},"end":{"line":1,"column":16,"index":16},"identifierName":"T"}, | ||
"name": "T" | ||
} | ||
}, | ||
"extendsType": { | ||
"type": "TSTupleType", | ||
"start":25,"end":52,"loc":{"start":{"line":1,"column":25,"index":25},"end":{"line":1,"column":52,"index":52}}, | ||
"elementTypes": [ | ||
{ | ||
"type": "TSConditionalType", | ||
"start":26,"end":51,"loc":{"start":{"line":1,"column":26,"index":26},"end":{"line":1,"column":51,"index":51}}, | ||
"checkType": { | ||
"type": "TSInferType", | ||
"start":26,"end":33,"loc":{"start":{"line":1,"column":26,"index":26},"end":{"line":1,"column":33,"index":33}}, | ||
"typeParameter": { | ||
"type": "TSTypeParameter", | ||
"start":32,"end":33,"loc":{"start":{"line":1,"column":32,"index":32},"end":{"line":1,"column":33,"index":33}}, | ||
"name": "U" | ||
} | ||
}, | ||
"extendsType": { | ||
"type": "TSTypeReference", | ||
"start":42,"end":43,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":43,"index":43}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":42,"end":43,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":43,"index":43},"identifierName":"T"}, | ||
"name": "T" | ||
} | ||
}, | ||
"trueType": { | ||
"type": "TSTypeReference", | ||
"start":46,"end":47,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":47,"index":47}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":46,"end":47,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":47,"index":47},"identifierName":"U"}, | ||
"name": "U" | ||
} | ||
}, | ||
"falseType": { | ||
"type": "TSTypeReference", | ||
"start":50,"end":51,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":51,"index":51}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":50,"end":51,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":51,"index":51},"identifierName":"T"}, | ||
"name": "T" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"trueType": { | ||
"type": "TSTypeReference", | ||
"start":55,"end":56,"loc":{"start":{"line":1,"column":55,"index":55},"end":{"line":1,"column":56,"index":56}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":55,"end":56,"loc":{"start":{"line":1,"column":55,"index":55},"end":{"line":1,"column":56,"index":56},"identifierName":"U"}, | ||
"name": "U" | ||
} | ||
}, | ||
"falseType": { | ||
"type": "TSTypeReference", | ||
"start":59,"end":60,"loc":{"start":{"line":1,"column":59,"index":59},"end":{"line":1,"column":60,"index":60}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":59,"end":60,"loc":{"start":{"line":1,"column":59,"index":59},"end":{"line":1,"column":60,"index":60},"identifierName":"T"}, | ||
"name": "T" | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...rser/test/fixtures/typescript/types/infer-with-constraints-and-conditional-types/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
type X<U, T> = T extends [infer U extends T ? U : T] ? U : T; |
3 changes: 3 additions & 0 deletions
3
.../test/fixtures/typescript/types/infer-with-constraints-and-conditional-types/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"BABEL_8_BREAKING": true | ||
} |
127 changes: 127 additions & 0 deletions
127
...r/test/fixtures/typescript/types/infer-with-constraints-and-conditional-types/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":61,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":61,"index":61}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":61,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":61,"index":61}}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "TSTypeAliasDeclaration", | ||
"start":0,"end":61,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":61,"index":61}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":5,"end":6,"loc":{"start":{"line":1,"column":5,"index":5},"end":{"line":1,"column":6,"index":6},"identifierName":"X"}, | ||
"name": "X" | ||
}, | ||
"typeParameters": { | ||
"type": "TSTypeParameterDeclaration", | ||
"start":6,"end":12,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":12,"index":12}}, | ||
"params": [ | ||
{ | ||
"type": "TSTypeParameter", | ||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":8,"index":8}}, | ||
"name": { | ||
"type": "Identifier", | ||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7,"index":7},"end":{"line":1,"column":8,"index":8},"identifierName":"U"}, | ||
"name": "U" | ||
} | ||
}, | ||
{ | ||
"type": "TSTypeParameter", | ||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":11,"index":11}}, | ||
"name": { | ||
"type": "Identifier", | ||
"start":10,"end":11,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":11,"index":11},"identifierName":"T"}, | ||
"name": "T" | ||
} | ||
} | ||
] | ||
}, | ||
"typeAnnotation": { | ||
"type": "TSConditionalType", | ||
"start":15,"end":60,"loc":{"start":{"line":1,"column":15,"index":15},"end":{"line":1,"column":60,"index":60}}, | ||
"checkType": { | ||
"type": "TSTypeReference", | ||
"start":15,"end":16,"loc":{"start":{"line":1,"column":15,"index":15},"end":{"line":1,"column":16,"index":16}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":15,"end":16,"loc":{"start":{"line":1,"column":15,"index":15},"end":{"line":1,"column":16,"index":16},"identifierName":"T"}, | ||
"name": "T" | ||
} | ||
}, | ||
"extendsType": { | ||
"type": "TSTupleType", | ||
"start":25,"end":52,"loc":{"start":{"line":1,"column":25,"index":25},"end":{"line":1,"column":52,"index":52}}, | ||
"elementTypes": [ | ||
{ | ||
"type": "TSConditionalType", | ||
"start":26,"end":51,"loc":{"start":{"line":1,"column":26,"index":26},"end":{"line":1,"column":51,"index":51}}, | ||
"checkType": { | ||
"type": "TSInferType", | ||
"start":26,"end":33,"loc":{"start":{"line":1,"column":26,"index":26},"end":{"line":1,"column":33,"index":33}}, | ||
"typeParameter": { | ||
"type": "TSTypeParameter", | ||
"start":32,"end":33,"loc":{"start":{"line":1,"column":32,"index":32},"end":{"line":1,"column":33,"index":33}}, | ||
"name": { | ||
"type": "Identifier", | ||
"start":32,"end":33,"loc":{"start":{"line":1,"column":32,"index":32},"end":{"line":1,"column":33,"index":33},"identifierName":"U"}, | ||
"name": "U" | ||
} | ||
} | ||
}, | ||
"extendsType": { | ||
"type": "TSTypeReference", | ||
"start":42,"end":43,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":43,"index":43}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":42,"end":43,"loc":{"start":{"line":1,"column":42,"index":42},"end":{"line":1,"column":43,"index":43},"identifierName":"T"}, | ||
"name": "T" | ||
} | ||
}, | ||
"trueType": { | ||
"type": "TSTypeReference", | ||
"start":46,"end":47,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":47,"index":47}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":46,"end":47,"loc":{"start":{"line":1,"column":46,"index":46},"end":{"line":1,"column":47,"index":47},"identifierName":"U"}, | ||
"name": "U" | ||
} | ||
}, | ||
"falseType": { | ||
"type": "TSTypeReference", | ||
"start":50,"end":51,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":51,"index":51}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":50,"end":51,"loc":{"start":{"line":1,"column":50,"index":50},"end":{"line":1,"column":51,"index":51},"identifierName":"T"}, | ||
"name": "T" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"trueType": { | ||
"type": "TSTypeReference", | ||
"start":55,"end":56,"loc":{"start":{"line":1,"column":55,"index":55},"end":{"line":1,"column":56,"index":56}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":55,"end":56,"loc":{"start":{"line":1,"column":55,"index":55},"end":{"line":1,"column":56,"index":56},"identifierName":"U"}, | ||
"name": "U" | ||
} | ||
}, | ||
"falseType": { | ||
"type": "TSTypeReference", | ||
"start":59,"end":60,"loc":{"start":{"line":1,"column":59,"index":59},"end":{"line":1,"column":60,"index":60}}, | ||
"typeName": { | ||
"type": "Identifier", | ||
"start":59,"end":60,"loc":{"start":{"line":1,"column":59,"index":59},"end":{"line":1,"column":60,"index":60},"identifierName":"T"}, | ||
"name": "T" | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/babel-parser/test/fixtures/typescript/types/infer-with-constraints-babel-7/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
type X3<T> = T extends [infer U extends number] ? MustBeNumber<U> : never; | ||
type X4<T> = T extends [infer U extends number, infer U extends number] ? MustBeNumber<U> : never; | ||
type X5<T> = T extends [infer U extends number, infer U] ? MustBeNumber<U> : never; | ||
type X6<T> = T extends [infer U, infer U extends number] ? MustBeNumber<U> : never; | ||
type X7<T> = T extends [infer U extends string, infer U extends number] ? U : never; | ||
type X8<U, T> = T extends infer U extends number ? U : T; | ||
type X9<U, T> = T extends (infer U extends number ? U : T) ? U : T; |
Oops, something went wrong.