Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix conditional type parsing association #253

Closed
wants to merge 1 commit into from
Closed
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
52 changes: 26 additions & 26 deletions common/corpus/types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1179,23 +1179,23 @@ type T<X> = T extends { x: infer X extends number } ? X : never;
(identifier)
(type_annotation (type_identifier))))
(conditional_type
(type_identifier)
(type_identifier)
(type_identifier)
(conditional_type
(type_identifier)
(function_type
(formal_parameters
(required_parameter
(identifier)
(type_annotation (type_identifier))))
(conditional_type
(type_identifier)
(type_identifier)
(type_identifier)
(type_identifier)))
(type_identifier)
(type_identifier)
(type_identifier))
(function_type
(formal_parameters
(required_parameter
(identifier)
(type_annotation (type_identifier))))
(conditional_type
(type_identifier)
(type_identifier)
(type_identifier)
(type_identifier)))
(type_identifier)
(type_identifier))))
(type_identifier)))))
(type_alias_declaration
(type_identifier)
(type_parameters
Expand All @@ -1205,20 +1205,20 @@ type T<X> = T extends { x: infer X extends number } ? X : never;
(type_identifier)
(generic_type
(type_identifier)
(type_arguments
(infer_type (type_identifier))))
(type_arguments (infer_type (type_identifier))))
(type_identifier)
(type_identifier)))
(type_alias_declaration
(type_alias_declaration
(type_identifier)
(type_parameters
(type_parameter (type_identifier)))
(conditional_type
(type_identifier)
(type_parameters
(type_parameter (type_identifier)))
(conditional_type
(type_identifier)
(array_type
(parenthesized_type (infer_type (type_identifier))))
(type_identifier)
(predefined_type)))
(array_type
(parenthesized_type
(infer_type (type_identifier))))
(type_identifier)
(predefined_type)))
(type_alias_declaration
(type_identifier)
(type_parameters
Expand Down Expand Up @@ -1568,7 +1568,7 @@ type Foo<T> = abstract new () => T;

---

(program (type_alias_declaration (type_identifier) (type_parameters (type_parameter (type_identifier))) (constructor_type (formal_parameters) (type_identifier))))
(program (type_alias_declaration (type_identifier) (type_parameters (type_parameter (type_identifier))) (constructor_type (formal_parameters) (type_identifier))))

=========================
Indexed Access Precedence
Expand Down
6 changes: 3 additions & 3 deletions common/define-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ module.exports = function defineGrammar(dialect) {
optional('declare'),
optional($.accessibility_modifier),
choice(
seq(optional('static'), optional($.override_modifier), optional('readonly')),
seq(optional('static'), optional($.override_modifier), optional('readonly')),
seq(optional('abstract'), optional('readonly')),
seq(optional('readonly'), optional('abstract')),
),
Expand Down Expand Up @@ -386,7 +386,7 @@ module.exports = function defineGrammar(dialect) {
// *definition*, not a declaration. Example:
// public foo()
// { <--- this brace made the method signature become a definition
// }
// }
// The same rule applies for functions and that's why we use
// "_function_signature_automatic_semicolon".
seq($.method_signature, choice($._function_signature_automatic_semicolon, ',')),
Expand Down Expand Up @@ -716,7 +716,7 @@ module.exports = function defineGrammar(dialect) {
))
)),

conditional_type: $ => prec.left(seq(
conditional_type: $ => prec.right(seq(
field('left', $._type),
'extends',
field('right', $._type),
Expand Down
2 changes: 1 addition & 1 deletion tsx/src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -8992,7 +8992,7 @@
}
},
"conditional_type": {
"type": "PREC_LEFT",
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
Expand Down
Loading