Skip to content

Commit

Permalink
fix(parser): parse true as TSLiteralType (#8626)
Browse files Browse the repository at this point in the history
closes #8624
  • Loading branch information
sxzz authored Jan 21, 2025
1 parent 2a2ad53 commit 48717ab
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 176 deletions.
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/ts/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ impl<'a> ParserImpl<'a> {
// return parseJSDocFunctionType();
Kind::Question => self.parse_js_doc_unknown_or_nullable_type(),
Kind::Bang => self.parse_js_doc_non_nullable_type(),
Kind::NoSubstitutionTemplate | Kind::Str | Kind::False | Kind::Null => {
Kind::NoSubstitutionTemplate | Kind::Str | Kind::True | Kind::False | Kind::Null => {
self.parse_literal_type_node(/* negative */ false)
}
kind if kind.is_number() => {
Expand Down
16 changes: 1 addition & 15 deletions tasks/coverage/snapshots/semantic_babel.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ commit: acbc09a8

semantic_babel Summary:
AST Parsed : 2292/2292 (100.00%)
Positive Passed: 1908/2292 (83.25%)
Positive Passed: 1909/2292 (83.29%)
tasks/coverage/babel/packages/babel-parser/test/fixtures/annex-b/enabled/3.3-function-in-if-body/input.js
semantic error: Symbol scope ID mismatch for "f":
after transform: SymbolId(0): ScopeId(4294967294)
Expand Down Expand Up @@ -179,9 +179,6 @@ tasks/coverage/babel/packages/babel-parser/test/fixtures/estree/typescript/liter
semantic error: Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(5), ScopeId(6), ScopeId(7)]
rebuilt : ScopeId(0): []
Unresolved references mismatch:
after transform: ["true"]
rebuilt : []

tasks/coverage/babel/packages/babel-parser/test/fixtures/estree/typescript/loc-index-property/input.js
semantic error: Bindings mismatch:
Expand Down Expand Up @@ -2289,17 +2286,11 @@ tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-argumen
semantic error: Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(5), ScopeId(6), ScopeId(7)]
rebuilt : ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(6), ScopeId(8)]
Unresolved references mismatch:
after transform: ["f", "true"]
rebuilt : ["f"]

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-asi-babel-7/input.ts
semantic error: Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(5), ScopeId(6), ScopeId(7)]
rebuilt : ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(6), ScopeId(8)]
Unresolved references mismatch:
after transform: ["f", "true"]
rebuilt : ["f"]

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-arguments/instantiation-expression-binary-operator/input.ts
semantic error: Unresolved references mismatch:
Expand Down Expand Up @@ -2552,11 +2543,6 @@ Unresolved references mismatch:
after transform: ["intrinsic"]
rebuilt : []
tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/types/literal-boolean/input.ts
semantic error: Unresolved references mismatch:
after transform: ["true"]
rebuilt : []
tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/types/literal-string-2/input.ts
semantic error: Unresolved references mismatch:
after transform: ["bar"]
Expand Down
Loading

0 comments on commit 48717ab

Please sign in to comment.