From 98ea5c5863802bcc6c2f9e961b42a173e38f6083 Mon Sep 17 00:00:00 2001 From: camc314 <18101008+camc314@users.noreply.github.com> Date: Fri, 27 Feb 2026 17:39:31 +0000 Subject: [PATCH] fix(parser): use TS8016 for type assertions in JS files diagnostic (#19818) https://github.com/microsoft/typescript/blob/0208948c95817bd7491111b40d6cf05013b21c4a/src/compiler/diagnosticMessages.json#L7002-L7005 This should be a 8016 error code, not 8037 --- crates/oxc_parser/src/diagnostics.rs | 2 +- tasks/coverage/snapshots/parser_misc.snap | 2 +- tasks/coverage/snapshots/parser_typescript.snap | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/oxc_parser/src/diagnostics.rs b/crates/oxc_parser/src/diagnostics.rs index 94525532c28e7..10b132267050e 100644 --- a/crates/oxc_parser/src/diagnostics.rs +++ b/crates/oxc_parser/src/diagnostics.rs @@ -1086,7 +1086,7 @@ pub fn decorator_on_overload(span: Span) -> OxcDiagnostic { #[cold] pub fn as_in_ts(span: Span) -> OxcDiagnostic { - ts_error("8037", "Type assertion expressions can only be used in TypeScript files.") + ts_error("8016", "Type assertion expressions can only be used in TypeScript files.") .with_label(span) } diff --git a/tasks/coverage/snapshots/parser_misc.snap b/tasks/coverage/snapshots/parser_misc.snap index 5ffb312ff62fa..1553977ab4539 100644 --- a/tasks/coverage/snapshots/parser_misc.snap +++ b/tasks/coverage/snapshots/parser_misc.snap @@ -3646,7 +3646,7 @@ Negative Passed: 134/134 (100.00%) ╰──── help: No modifiers are allowed here. - × TS(8037): Type assertion expressions can only be used in TypeScript files. + × TS(8016): Type assertion expressions can only be used in TypeScript files. ╭─[misc/fail/oxc-4111-1.js:1:1] 1 │ funtransientction as longciiConÞr>ol(cde) { · ───────────────────────────────── diff --git a/tasks/coverage/snapshots/parser_typescript.snap b/tasks/coverage/snapshots/parser_typescript.snap index b439957d0e5e5..762d746869f6c 100644 --- a/tasks/coverage/snapshots/parser_typescript.snap +++ b/tasks/coverage/snapshots/parser_typescript.snap @@ -7443,7 +7443,7 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc 2 │ Foo(1); ╰──── - × TS(8037): Type assertion expressions can only be used in TypeScript files. + × TS(8016): Type assertion expressions can only be used in TypeScript files. ╭─[typescript/tests/cases/compiler/jsFileCompilationTypeAssertions.ts:1:1] 1 │ 0 as number; · ───────────