diff --git a/crates/oxc_parser/src/ts/statement.rs b/crates/oxc_parser/src/ts/statement.rs index 1e0d5b8e9b9e0..37af36f119a18 100644 --- a/crates/oxc_parser/src/ts/statement.rs +++ b/crates/oxc_parser/src/ts/statement.rs @@ -124,7 +124,13 @@ impl<'a> ParserImpl<'a> { let params = self.parse_ts_type_parameters()?; self.expect(Kind::Eq)?; - let annotation = self.parse_ts_type()?; + let annotation = if self.at(Kind::Intrinsic) && !self.peek_at(Kind::Dot) { + let span = self.start_span(); + self.bump_any(); + self.ast.ts_type_intrinsic_keyword(self.end_span(span)) + } else { + self.parse_ts_type()? + }; self.asi()?; let span = self.end_span(span); diff --git a/crates/oxc_parser/src/ts/types.rs b/crates/oxc_parser/src/ts/types.rs index 85dcf1f6fffa4..78ded08bd1e5a 100644 --- a/crates/oxc_parser/src/ts/types.rs +++ b/crates/oxc_parser/src/ts/types.rs @@ -433,10 +433,6 @@ impl<'a> ParserImpl<'a> { self.bump_any(); self.ast.ts_type_boolean_keyword(self.end_span(span)) } - Kind::Intrinsic => { - self.bump_any(); - self.ast.ts_type_intrinsic_keyword(self.end_span(span)) - } Kind::Never => { self.bump_any(); self.ast.ts_type_never_keyword(self.end_span(span)) diff --git a/tasks/coverage/snapshots/parser_babel.snap b/tasks/coverage/snapshots/parser_babel.snap index dea097fa0d867..0849a397dd3a3 100644 --- a/tasks/coverage/snapshots/parser_babel.snap +++ b/tasks/coverage/snapshots/parser_babel.snap @@ -3,7 +3,7 @@ commit: acbc09a8 parser_babel Summary: AST Parsed : 2277/2292 (99.35%) Positive Passed: 2256/2292 (98.43%) -Negative Passed: 1541/1662 (92.72%) +Negative Passed: 1542/1662 (92.78%) Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/annex-b/enabled/3.1-sloppy-labeled-functions-if-body/input.js Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-if/input.js Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/input.js @@ -121,7 +121,6 @@ Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/ty Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/types/import-type-declaration-error/input.ts Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/types/import-type-dynamic-errors/input.ts Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/types/import-type-dynamic-errors-babel-7/input.ts -Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/types/intrinsic-keyword-error/input.ts Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/types/tuple-labeled-invalid-optional/input.ts Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/types/tuple-optional-invalid/input.ts Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/types/tuple-required-after-labeled-optional/input.ts @@ -12756,6 +12755,14 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc · ───────── ╰──── + × Expected a semicolon or an implicit semicolon after a statement, but found none + ╭─[babel/packages/babel-parser/test/fixtures/typescript/types/intrinsic-keyword-error/input.ts:1:21] + 1 │ type Foo = intrinsic["foo"]; + · ▲ + 2 │ + ╰──── + help: Try insert a semicolon here + × Unexpected token ╭─[babel/packages/babel-parser/test/fixtures/typescript/types/literal-string-3/input.ts:1:19] 1 │ let x: `foo-${bar + baz}`; diff --git a/tasks/coverage/snapshots/semantic_babel.snap b/tasks/coverage/snapshots/semantic_babel.snap index a4ae2f95941ad..a2310fe7ea7f6 100644 --- a/tasks/coverage/snapshots/semantic_babel.snap +++ b/tasks/coverage/snapshots/semantic_babel.snap @@ -2540,17 +2540,11 @@ tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/types/intrin semantic error: Scope children mismatch: after transform: ScopeId(0): [ScopeId(1), ScopeId(2)] rebuilt : ScopeId(0): [] -Unresolved references mismatch: -after transform: ["intrinsic"] -rebuilt : [] tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/types/intrinsic-keyword-babel-7/input.ts semantic error: Scope children mismatch: after transform: ScopeId(0): [ScopeId(1), ScopeId(2)] rebuilt : ScopeId(0): [] -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: