diff --git a/crates/tsrs_lint/src/rules/no_base_to_string.rs b/crates/tsrs_lint/src/rules/no_base_to_string.rs index 43f41ce52..5346c2c53 100644 --- a/crates/tsrs_lint/src/rules/no_base_to_string.rs +++ b/crates/tsrs_lint/src/rules/no_base_to_string.rs @@ -3,13 +3,14 @@ use rustc_hash::{FxHashMap, FxHashSet}; use tsrs_ast::{self as ast, Kind, Node}; use tsrs_checker::{self as checker, Checker, Type, TypeFlags}; +use tsrs_compiler::Program; use tsrs_core::{P, json::Value}; use crate::protocol::RuleMessage; use crate::rule::{Listener, Rule, RuleContext, trim_node_range}; use crate::utils::{ get_constrained_type_at_location, get_type_name, is_builtin_symbol_like, - matches_type_or_base_type, + is_symbol_from_default_library, matches_type_or_base_type, }; #[derive(Clone, Copy, PartialEq, Eq)] @@ -53,6 +54,33 @@ impl CertaintyMemo { } } +fn is_symbol_to_primitive_method( + program: &Program, + checker: &mut Checker, + declaration: P, +) -> bool { + if declaration.kind() != Kind::MethodSignature { + return false; + } + let Some(name) = declaration.name().filter(|&name| name.kind() == Kind::ComputedPropertyName) + else { + return false; + }; + let expression = name.expression().unwrap(); + if expression.kind() != Kind::PropertyAccessExpression { + return false; + } + let object = expression.expression().unwrap(); + let name = expression.name().unwrap(); + ast::is_identifier(object) + && object.text() == "Symbol" + && ast::is_identifier(name) + && name.text() == "toPrimitive" + && checker + .get_symbol_at_location_exported(object) + .is_some_and(|symbol| is_symbol_from_default_library(program, symbol)) +} + pub struct NoBaseToString { check_unknown: bool, ignored_type_names: Vec, @@ -96,6 +124,7 @@ impl NoBaseToString { fn collect_union_type_certainty( &mut self, + program: &Program, checker: &mut Checker, t: P, visited: &[P], @@ -105,9 +134,9 @@ impl NoBaseToString { let mut all_always = true; for &part in t.types() { let value = if join { - self.collect_join_certainty(checker, part, visited) + self.collect_join_certainty(program, checker, part, visited) } else { - self.collect_to_string_certainty(checker, part, visited) + self.collect_to_string_certainty(program, checker, part, visited) }; all_never &= value == Usefulness::Never; all_always &= value == Usefulness::Always; @@ -123,6 +152,7 @@ impl NoBaseToString { fn collect_intersection_type_certainty( &mut self, + program: &Program, checker: &mut Checker, t: P, visited: &[P], @@ -130,9 +160,9 @@ impl NoBaseToString { ) -> Usefulness { if t.types().iter().any(|&part| { let value = if join { - self.collect_join_certainty(checker, part, visited) + self.collect_join_certainty(program, checker, part, visited) } else { - self.collect_to_string_certainty(checker, part, visited) + self.collect_to_string_certainty(program, checker, part, visited) }; value == Usefulness::Always }) { @@ -144,6 +174,7 @@ impl NoBaseToString { fn collect_tuple_certainty( &mut self, + program: &Program, checker: &mut Checker, t: P, visited: &[P], @@ -151,7 +182,7 @@ impl NoBaseToString { let mut never = false; let mut sometimes = false; for &argument in checker.get_type_arguments(t) { - let value = self.collect_to_string_certainty(checker, argument, visited); + let value = self.collect_to_string_certainty(program, checker, argument, visited); never |= value == Usefulness::Never; sometimes |= value == Usefulness::Sometimes; } @@ -166,6 +197,7 @@ impl NoBaseToString { fn collect_array_certainty( &mut self, + program: &Program, checker: &mut Checker, t: P, visited: &[P], @@ -173,11 +205,12 @@ impl NoBaseToString { let element = checker .get_index_type_of_type(t, checker.number_type) .expect("array should have number index type"); - self.collect_to_string_certainty(checker, element, visited) + self.collect_to_string_certainty(program, checker, element, visited) } fn collect_join_certainty( &mut self, + program: &Program, checker: &mut Checker, t: P, visited: &[P], @@ -186,13 +219,13 @@ impl NoBaseToString { return value; } let value = if t.flags().intersects(TypeFlags::Union) { - self.collect_union_type_certainty(checker, t, visited, true) + self.collect_union_type_certainty(program, checker, t, visited, true) } else if t.flags().intersects(TypeFlags::Intersection) { - self.collect_intersection_type_certainty(checker, t, visited, true) + self.collect_intersection_type_certainty(program, checker, t, visited, true) } else if checker::is_tuple_type_exported(t) { - self.collect_tuple_certainty(checker, t, visited) + self.collect_tuple_certainty(program, checker, t, visited) } else if checker.is_array_type(t) { - self.collect_array_certainty(checker, t, visited) + self.collect_array_certainty(program, checker, t, visited) } else { Usefulness::Always }; @@ -201,6 +234,7 @@ impl NoBaseToString { fn collect_to_string_certainty( &mut self, + program: &Program, checker: &mut Checker, t: P, visited: &[P], @@ -211,19 +245,20 @@ impl NoBaseToString { if let Some(value) = self.to_string_memo.start(t) { return value; } - let value = self.compute_to_string_certainty(checker, t, visited); + let value = self.compute_to_string_certainty(program, checker, t, visited); self.to_string_memo.finish(t, value) } fn compute_to_string_certainty( &mut self, + program: &Program, checker: &mut Checker, t: P, visited: &[P], ) -> Usefulness { if t.flags().intersects(TypeFlags::TypeParameter) { return if let Some(constraint) = checker.get_base_constraint_of_type(t) { - self.collect_to_string_certainty(checker, constraint, visited) + self.collect_to_string_certainty(program, checker, constraint, visited) } else if self.check_unknown { Usefulness::Sometimes } else { @@ -240,20 +275,27 @@ impl NoBaseToString { return Usefulness::Always; } if t.flags().intersects(TypeFlags::Intersection) { - return self.collect_intersection_type_certainty(checker, t, visited, false); + return self.collect_intersection_type_certainty(program, checker, t, visited, false); } if t.flags().intersects(TypeFlags::Union) { - return self.collect_union_type_certainty(checker, t, visited, false); + return self.collect_union_type_certainty(program, checker, t, visited, false); } if checker::is_tuple_type_exported(t) || checker.is_array_type(t) { let mut visited = visited.to_vec(); visited.push(t); return if checker::is_tuple_type_exported(t) { - self.collect_tuple_certainty(checker, t, &visited) + self.collect_tuple_certainty(program, checker, t, &visited) } else { - self.collect_array_certainty(checker, t, &visited) + self.collect_array_certainty(program, checker, t, &visited) }; } + if checker.get_properties_of_type(t).iter().any(|property| { + property.value_declaration().is_some_and(|declaration| { + is_symbol_to_primitive_method(program, checker, declaration) + }) + }) { + return Usefulness::Always; + } let mut found_fallback_on_object = false; for name in ["toString", "toLocaleString", "valueOf"] { let Some(property) = checker.get_property_of_type(t, name) else { @@ -320,7 +362,7 @@ impl NoBaseToString { return; } let t = t.unwrap_or_else(|| context.checker.get_type_at_location(node)); - let certainty = self.collect_to_string_certainty(context.checker, t, &[]); + let certainty = self.collect_to_string_certainty(context.program, context.checker, t, &[]); Self::report(node, certainty, false, context); } } @@ -384,7 +426,12 @@ impl Rule for NoBaseToString { context.checker, member.expression, ); - let certainty = self.collect_join_certainty(context.checker, t, &[]); + let certainty = self.collect_join_certainty( + context.program, + context.checker, + t, + &[], + ); Self::report(member.expression, certainty, true, context); } "toLocaleString" | "toString" => { diff --git a/crates/tsrs_lint/tests/baselines/PROGRESS.md b/crates/tsrs_lint/tests/baselines/PROGRESS.md index 2af74f02a..cf6836a45 100644 --- a/crates/tsrs_lint/tests/baselines/PROGRESS.md +++ b/crates/tsrs_lint/tests/baselines/PROGRESS.md @@ -14,7 +14,7 @@ and suggestions before its implementation commit. Upstream skips remain explicit | consistent-type-exports | Updated to Go HEAD | 49 current cases; source overrides and both mixed-export fix modes | | dot-notation | Updated to Go HEAD | 75 current cases; Go regex quoting, groups, classes, repetitions, Unicode properties, and octal escapes | | no-array-delete | Updated to Go HEAD | 31 current cases; suggestion flags and UTF-8 ranges | -| no-base-to-string | Updated to Go HEAD | 380 current cases, 1 upstream skips; conversions/joins, recursive types, ignored names, checkUnknown | +| no-base-to-string | Updated to 7f5c22e5 | 384 current cases, 1 upstream skips; `Symbol.toPrimitive` methods, conversions/joins, recursive types, ignored names, checkUnknown | | no-confusing-void-expression | Updated to Go HEAD | 109 current cases, 1 upstream skips; arrow/return fixes, contextual void, option combinations | | no-deprecated | Updated to Go HEAD | 242 current cases, 12 upstream skips; aliases, circular alias chains, signatures, contextual properties, destructuring, allow specifiers | | no-duplicate-type-constituents | Updated to 840816e9 | 89 current cases, 2 upstream skips; nested unions/intersections, optional parameter fixes, multiline JSDoc ranges and fixes after template literal types | diff --git a/crates/tsrs_lint/tests/baselines/no-base-to-string/REFERENCE b/crates/tsrs_lint/tests/baselines/no-base-to-string/REFERENCE index 9b842313e..14b2915d1 100644 --- a/crates/tsrs_lint/tests/baselines/no-base-to-string/REFERENCE +++ b/crates/tsrs_lint/tests/baselines/no-base-to-string/REFERENCE @@ -1,2 +1,2 @@ -tsgolint 4ebf80fd2b166cba4890c6896220fec4a1462b29 +tsgolint 7f5c22e5ef395c19f854d5c84c195025c4480a53 typescript-go 2bd066d87f5bafd315be9f40889d0a60b9e58e0b diff --git a/crates/tsrs_lint/tests/baselines/no-base-to-string/baseline.json b/crates/tsrs_lint/tests/baselines/no-base-to-string/baseline.json index f91ee197a..b3046fe1d 100644 --- a/crates/tsrs_lint/tests/baselines/no-base-to-string/baseline.json +++ b/crates/tsrs_lint/tests/baselines/no-base-to-string/baseline.json @@ -2116,6 +2116,28 @@ "Files": {}, "Diagnostics": [] }, + { + "Code": "\ndeclare const a: {\n [Symbol.toPrimitive](): string;\n};\n\n`${a}`;\n ", + "Only": false, + "Skip": false, + "FileName": "", + "Options": null, + "TSConfig": "", + "Tsx": false, + "Files": {}, + "Diagnostics": [] + }, + { + "Code": "\ndeclare const a: {\n valueOf(): string;\n};\n\n`${a}`;\n ", + "Only": false, + "Skip": false, + "FileName": "", + "Options": null, + "TSConfig": "", + "Tsx": false, + "Files": {}, + "Diagnostics": [] + }, { "Code": "\nfunction someFunction() {}\nsomeFunction.toString();\nlet text = `${someFunction}`;\n ", "Only": false, @@ -5117,6 +5139,80 @@ } ] }, + { + "Code": "\n declare const a:\n | {\n [Symbol.toPrimitive](): string;\n }\n | {\n other: true;\n };\n\n `${a}`;\n ", + "Only": false, + "Skip": false, + "FileName": "", + "Output": [], + "Errors": [ + { + "MessageId": "baseToString", + "Line": 10, + "Column": 12, + "EndLine": 0, + "EndColumn": 0, + "Suggestions": [] + } + ], + "TSConfig": "", + "Options": null, + "Tsx": false, + "Files": {}, + "Diagnostics": [ + { + "kind": 0, + "rule": "no-base-to-string", + "message": { + "id": "baseToString", + "description": "'a' may use Object's default stringification format ('[object Object]') when stringified.", + "help": "Consider picking a property (e.g. `user.name`), using a formatter (or `JSON.stringify`), or implementing a custom `toString()`/`toLocaleString()` on the type." + }, + "file_path": "file.ts", + "range": { + "pos": 168, + "end": 169 + } + } + ] + }, + { + "Code": "\n declare const a:\n | {\n valueOf(): string;\n }\n | {\n other: true;\n };\n\n `${a}`;\n ", + "Only": false, + "Skip": false, + "FileName": "", + "Output": [], + "Errors": [ + { + "MessageId": "baseToString", + "Line": 10, + "Column": 12, + "EndLine": 0, + "EndColumn": 0, + "Suggestions": [] + } + ], + "TSConfig": "", + "Options": null, + "Tsx": false, + "Files": {}, + "Diagnostics": [ + { + "kind": 0, + "rule": "no-base-to-string", + "message": { + "id": "baseToString", + "description": "'a' may use Object's default stringification format ('[object Object]') when stringified.", + "help": "Consider picking a property (e.g. `user.name`), using a formatter (or `JSON.stringify`), or implementing a custom `toString()`/`toLocaleString()` on the type." + }, + "file_path": "file.ts", + "range": { + "pos": 155, + "end": 156 + } + } + ] + }, { "Code": "\n [{}, {}].toString();\n ", "Only": false, diff --git a/docs/COMPATIBILITY.md b/docs/COMPATIBILITY.md index e282177e1..2af70225e 100644 --- a/docs/COMPATIBILITY.md +++ b/docs/COMPATIBILITY.md @@ -53,7 +53,7 @@ have been available since 0.20.0. | feature | status | evidence and notes | | --- | --- | --- | -| Type-aware linting | 62 rules | Rust headless binary `tsrs-lint`, also `tsrs --lint` (the npm `tsrs-lint` command), implements 62/62 pinned tsgolint rules; 8221 imported active case inputs pass, 28 upstream skips; the base corpus follows rebuilt tsgolint v7.0.2005 ([reference](../crates/tsrs_lint/tests/baselines/REFERENCE)), with per-rule scoped refreshes; no-misused-promises accepts `checksConditionals: { flagUnions }` from upstream #1353 ([reference](../crates/tsrs_lint/tests/baselines/no-misused-promises/REFERENCE)); no-unsafe-class-instance-assignment is added from upstream #1372 with the recursive comparison guard from #1373 ([reference](../crates/tsrs_lint/tests/baselines/no-unsafe-class-instance-assignment/REFERENCE)); no-meaningless-void-operator reports `void` on non-call operands from upstream #1375 ([reference](../crates/tsrs_lint/tests/baselines/no-meaningless-void-operator/REFERENCE)); restrict-template-expressions handles recursive arrays and tuples with `allowArray` from upstream #1377 ([reference](../crates/tsrs_lint/tests/baselines/restrict-template-expressions/REFERENCE)); non-nullable-type-assertion-style ignores JSDoc casts in JavaScript files from upstream #1286 ([reference](../crates/tsrs_lint/tests/baselines/non-nullable-type-assertion-style/REFERENCE)); no-duplicate-type-constituents fixes a duplicate after a template literal type without panicking from upstream #1389 ([reference](../crates/tsrs_lint/tests/baselines/no-duplicate-type-constituents/REFERENCE)); no-unnecessary-boolean-literal-compare treats a union as a nullable boolean only when its non-nullish members are all boolean, from upstream #1401 ([reference](../crates/tsrs_lint/tests/baselines/no-unnecessary-boolean-literal-compare/REFERENCE)); no-mixed-enums reads the desired member type from an earlier non-empty enum declaration without panicking from upstream #1400 ([reference](../crates/tsrs_lint/tests/baselines/no-mixed-enums/REFERENCE)); the lint traversal visits computed property names in destructuring assignments from upstream #1396 ([reference](../crates/tsrs_lint/tests/baselines/await-thenable/REFERENCE)); no-floating-promises skips parentheses around nested operands from upstream #1399 ([reference](../crates/tsrs_lint/tests/baselines/no-floating-promises/REFERENCE)); no-unnecessary-template-expression autofixes single interpolations only for exact `string` expressions and suggests narrowing removals from upstream #1367 ([reference](../crates/tsrs_lint/tests/baselines/no-unnecessary-template-expression/REFERENCE)); prefer-optional-chain includes 1178 cases, including JSX callback coverage from upstream #1335 ([reference](../crates/tsrs_lint/tests/baselines/prefer-optional-chain/REFERENCE)); no-unnecessary-type-assertion reports assertions that infer generic call type arguments without an autofix, and under `exactOptionalPropertyTypes` compares only the non-`undefined` members of unions that include `undefined` from upstream #1390 ([reference](../crates/tsrs_lint/tests/baselines/no-unnecessary-type-assertion/REFERENCE)); untyped explicit `this` parameters are handled without the current Go HEAD panic ([regression](../crates/tsrs_lint/tests/integration/headless.rs)); a relative type reference that reaches a symlinked package through a type root does not panic in a program with project references ([regression](../crates/tsrs_compiler/tests/integration/typeroot_candidate_test.rs)); `types: ["*"]` lists type roots without panicking in a program with project references ([regression](../crates/tsrs_compiler/tests/integration/program_test.rs)); diagnostics whose text holds a lone surrogate are reported where Go silently drops them ([investigation](../notes/tsgolint-diagnostic-parity.md)); identified rule-version gaps are synchronized to Go HEAD ([refresh evidence](../notes/tsgolint-head-refresh.md)); compiler-version and corpus-order differences remain documented ([investigation](../notes/tsgolint-diagnostic-parity.md)) ([progress](../crates/tsrs_lint/tests/baselines/PROGRESS.md), [baseline tests](../crates/tsrs_lint/tests/integration/baselines.rs)); recursive type-reference traversal includes the newer Go fix ([evidence](../crates/tsrs_lint/tests/fixtures/type_parameter_references/REFERENCE)); V1/V2 payloads reject unpaired JSON surrogate escapes ([protocol tests](../crates/tsrs_lint/tests/integration/protocol.rs)); custom-named configs reached through transitive project references retain inherited compiler options, including in deeper and diamond graphs ([discovery tests](../crates/tsrs_lint/tests/integration/engine_test.rs)); program loading/binding uses the compiler's parallel pool (default up to 32 threads, `RAYON_NUM_THREADS` override) with per-program allocation regions and honors `singleThreaded`; programs in one headless request share parsed extended and referenced-project configs and parsed/bound declaration files in request-owned regions, and a tsconfig program reuses its discovery parse when its config path has the spelling discovery parsed ([#949](https://github.com/oxc-project/tsrs/pull/949), [#950](https://github.com/oxc-project/tsrs/pull/950), [#951](https://github.com/oxc-project/tsrs/pull/951), [issue #1016](https://github.com/oxc-project/tsrs/issues/1016)); linting and requested semantic diagnostics run on each program's checker pool with the fast preset enabled by default (`TSRS_FAST=0` disables it; a positive `RAYON_NUM_THREADS` or a tsconfig `checkers` option sets the count), free the checkers with the program and retain file-order output frames; requested syntactic and semantic diagnostics (oxlint `--type-check`) cover only the files the request lists, as tsgolint does: other program files are not reported, global diagnostics are reported once per program on its tsconfig, declaration diagnostics are reported when `declaration` or `composite` is set, and listed files outside every tsconfig are type-checked in an inferred program ([regressions](../crates/tsrs_lint/tests/integration/headless.rs)); type-check diagnostics include a `category` field (`error`, `warning`, or `message`) so oxlint can map plugin warnings to warnings instead of errors (#1031, [regression](../crates/tsrs_lint/tests/integration/headless.rs)); each type error's description has its message chain, one line for each message, as `tsc` prints it, where tsgolint sends only the first line ([regression](../crates/tsrs_lint/tests/integration/headless.rs)); with semantic reporting enabled, every listed file is type-checked before rules run, so errors retain their file locations ([#955](https://github.com/oxc-project/tsrs/pull/955)); semantic reporting and linting share the pool checker that owns each file, accepting history-dependent diagnostics and fixes ([evidence](../notes/perf-tsgolint-shared-checker.md)); switch default-case comments honor the default marker and custom ECMAScript patterns, including lookarounds, backreferences and scoped `i`/`m`/`s` modifiers ([oracle regressions](../crates/tsrs_lint/tests/fixtures/switch_exhaustiveness_check/REFERENCE)); invalid patterns return protocol errors; virtual source overrides participate in package resolution and include globs ([overlay test](../crates/tsrs_lint/tests/integration/headless.rs)) ([concurrency test](../crates/tsrs_lint/tests/integration/headless.rs), [lifecycle tests](../crates/tsrs_lint/tests/integration/lifecycle.rs), [binding ownership test](../crates/tsrs_compiler/tests/integration/programregions_test.rs)) | +| Type-aware linting | 62 rules | Rust headless binary `tsrs-lint`, also `tsrs --lint` (the npm `tsrs-lint` command), implements 62/62 pinned tsgolint rules; 8225 imported active case inputs pass, 28 upstream skips; the base corpus follows rebuilt tsgolint v7.0.2005 ([reference](../crates/tsrs_lint/tests/baselines/REFERENCE)), with per-rule scoped refreshes; no-misused-promises accepts `checksConditionals: { flagUnions }` from upstream #1353 ([reference](../crates/tsrs_lint/tests/baselines/no-misused-promises/REFERENCE)); no-unsafe-class-instance-assignment is added from upstream #1372 with the recursive comparison guard from #1373 ([reference](../crates/tsrs_lint/tests/baselines/no-unsafe-class-instance-assignment/REFERENCE)); no-meaningless-void-operator reports `void` on non-call operands from upstream #1375 ([reference](../crates/tsrs_lint/tests/baselines/no-meaningless-void-operator/REFERENCE)); restrict-template-expressions handles recursive arrays and tuples with `allowArray` from upstream #1377 ([reference](../crates/tsrs_lint/tests/baselines/restrict-template-expressions/REFERENCE)); non-nullable-type-assertion-style ignores JSDoc casts in JavaScript files from upstream #1286 ([reference](../crates/tsrs_lint/tests/baselines/non-nullable-type-assertion-style/REFERENCE)); no-duplicate-type-constituents fixes a duplicate after a template literal type without panicking from upstream #1389 ([reference](../crates/tsrs_lint/tests/baselines/no-duplicate-type-constituents/REFERENCE)); no-base-to-string treats a `[Symbol.toPrimitive]` method as custom stringification from upstream #1398 ([reference](../crates/tsrs_lint/tests/baselines/no-base-to-string/REFERENCE)); no-unnecessary-boolean-literal-compare treats a union as a nullable boolean only when its non-nullish members are all boolean, from upstream #1401 ([reference](../crates/tsrs_lint/tests/baselines/no-unnecessary-boolean-literal-compare/REFERENCE)); no-mixed-enums reads the desired member type from an earlier non-empty enum declaration without panicking from upstream #1400 ([reference](../crates/tsrs_lint/tests/baselines/no-mixed-enums/REFERENCE)); the lint traversal visits computed property names in destructuring assignments from upstream #1396 ([reference](../crates/tsrs_lint/tests/baselines/await-thenable/REFERENCE)); no-floating-promises skips parentheses around nested operands from upstream #1399 ([reference](../crates/tsrs_lint/tests/baselines/no-floating-promises/REFERENCE)); no-unnecessary-template-expression autofixes single interpolations only for exact `string` expressions and suggests narrowing removals from upstream #1367 ([reference](../crates/tsrs_lint/tests/baselines/no-unnecessary-template-expression/REFERENCE)); prefer-optional-chain includes 1178 cases, including JSX callback coverage from upstream #1335 ([reference](../crates/tsrs_lint/tests/baselines/prefer-optional-chain/REFERENCE)); no-unnecessary-type-assertion reports assertions that infer generic call type arguments without an autofix, and under `exactOptionalPropertyTypes` compares only the non-`undefined` members of unions that include `undefined` from upstream #1390 ([reference](../crates/tsrs_lint/tests/baselines/no-unnecessary-type-assertion/REFERENCE)); untyped explicit `this` parameters are handled without the current Go HEAD panic ([regression](../crates/tsrs_lint/tests/integration/headless.rs)); a relative type reference that reaches a symlinked package through a type root does not panic in a program with project references ([regression](../crates/tsrs_compiler/tests/integration/typeroot_candidate_test.rs)); `types: ["*"]` lists type roots without panicking in a program with project references ([regression](../crates/tsrs_compiler/tests/integration/program_test.rs)); diagnostics whose text holds a lone surrogate are reported where Go silently drops them ([investigation](../notes/tsgolint-diagnostic-parity.md)); identified rule-version gaps are synchronized to Go HEAD ([refresh evidence](../notes/tsgolint-head-refresh.md)); compiler-version and corpus-order differences remain documented ([investigation](../notes/tsgolint-diagnostic-parity.md)) ([progress](../crates/tsrs_lint/tests/baselines/PROGRESS.md), [baseline tests](../crates/tsrs_lint/tests/integration/baselines.rs)); recursive type-reference traversal includes the newer Go fix ([evidence](../crates/tsrs_lint/tests/fixtures/type_parameter_references/REFERENCE)); V1/V2 payloads reject unpaired JSON surrogate escapes ([protocol tests](../crates/tsrs_lint/tests/integration/protocol.rs)); custom-named configs reached through transitive project references retain inherited compiler options, including in deeper and diamond graphs ([discovery tests](../crates/tsrs_lint/tests/integration/engine_test.rs)); program loading/binding uses the compiler's parallel pool (default up to 32 threads, `RAYON_NUM_THREADS` override) with per-program allocation regions and honors `singleThreaded`; programs in one headless request share parsed extended and referenced-project configs and parsed/bound declaration files in request-owned regions, and a tsconfig program reuses its discovery parse when its config path has the spelling discovery parsed ([#949](https://github.com/oxc-project/tsrs/pull/949), [#950](https://github.com/oxc-project/tsrs/pull/950), [#951](https://github.com/oxc-project/tsrs/pull/951), [issue #1016](https://github.com/oxc-project/tsrs/issues/1016)); linting and requested semantic diagnostics run on each program's checker pool with the fast preset enabled by default (`TSRS_FAST=0` disables it; a positive `RAYON_NUM_THREADS` or a tsconfig `checkers` option sets the count), free the checkers with the program and retain file-order output frames; requested syntactic and semantic diagnostics (oxlint `--type-check`) cover only the files the request lists, as tsgolint does: other program files are not reported, global diagnostics are reported once per program on its tsconfig, declaration diagnostics are reported when `declaration` or `composite` is set, and listed files outside every tsconfig are type-checked in an inferred program ([regressions](../crates/tsrs_lint/tests/integration/headless.rs)); type-check diagnostics include a `category` field (`error`, `warning`, or `message`) so oxlint can map plugin warnings to warnings instead of errors (#1031, [regression](../crates/tsrs_lint/tests/integration/headless.rs)); each type error's description has its message chain, one line for each message, as `tsc` prints it, where tsgolint sends only the first line ([regression](../crates/tsrs_lint/tests/integration/headless.rs)); with semantic reporting enabled, every listed file is type-checked before rules run, so errors retain their file locations ([#955](https://github.com/oxc-project/tsrs/pull/955)); semantic reporting and linting share the pool checker that owns each file, accepting history-dependent diagnostics and fixes ([evidence](../notes/perf-tsgolint-shared-checker.md)); switch default-case comments honor the default marker and custom ECMAScript patterns, including lookarounds, backreferences and scoped `i`/`m`/`s` modifiers ([oracle regressions](../crates/tsrs_lint/tests/fixtures/switch_exhaustiveness_check/REFERENCE)); invalid patterns return protocol errors; virtual source overrides participate in package resolution and include globs ([overlay test](../crates/tsrs_lint/tests/integration/headless.rs)) ([concurrency test](../crates/tsrs_lint/tests/integration/headless.rs), [lifecycle tests](../crates/tsrs_lint/tests/integration/lifecycle.rs), [binding ownership test](../crates/tsrs_compiler/tests/integration/programregions_test.rs)) | | JSON Unicode escape validation | partial | Lint payloads use the API transport's strict decoder, which rejects unpaired surrogate escapes with pinned Go's error text. The native Rust JSON decoder (`tsrs_core::json`) replaces them with U+FFFD, whereas pinned Go rejects them ([protocol tests](../crates/tsrs_lint/tests/integration/protocol.rs), [headless tests](../crates/tsrs_lint/tests/integration/headless.rs)) | | Type checking (`--noEmit`) | yes | All 13,700 error baselines and 12,998 `.types` / `.symbols` baselines match in both histories with the upstream emit sequence; flow-memo keys preserve full-width pointers on Windows and other 64-bit plain-pointer builds, keeping type-query initial states distinct (`recursiveTypesWithTypeof`, `stringLiteralsWithTypeAssertions01`); reserved high-range symbol IDs keep diagnostic truncation aligned with Go (`unique-symbol-link-id-truncation`); `using` with only `[Symbol.asyncDispose]` suggests `await using` (`usingAsyncDisposable`); JS classes eagerly check their own constructor-declared properties after their members, making implicit-any diagnostics stable for both class declarations and expressions (`flakyDiagnosticsJsClassPropertyInitializedToUndefined`); inferred type parameters are sorted by `CompareTypes` before constructing conditional type mappers (`stableTypeMapperOrdering`); merged-interface TS2320/TS2430 errors belong to the first declaration regardless of checker visit order, including when that declaration is in a skipped library (`mergedInterfaceAugmentationDiagnostics`, `mergedInterfaceDefaultLibraryDiagnostics`, `mergedInterfaceInheritanceDiagnostics`); type-argument inference caches distinct priority and variance states and reports the expected TS2345 for correlated union arguments (`inference-type-argument-variance`); static properties avoid contextual typing by their own class and spurious circularity errors (`classStaticPropertyNoSpuriousCircularityError1`); module import attribute types require string literals and reject template literals (`importAttributeType1`); pure return-type inference remains filtered by its constraint during recursive calls (`recursiveTypeInferenceReturnTypeConstraint`); the corrected `customConditions` fixture exercises both conditions and selects `browser` with package exports enabled, `index` with them disabled; empty and dot filename stems, trailing-slash type references, and NodeNext directory-import TS2834 match source 31; `typeof import()` qualifier names do not add emit-only missing-name diagnostics (`noFlakyDiagnosticsTypeofImportTypeQualifier1`, `noFlakyDiagnosticsTypeofImportTypeQualifier2`); deferred imports without namespace bindings report TS18117, including in unchecked JavaScript (`importDeferInvalidDefault`); enum computed-name expressions are checked even when their names have a grammar error, preserving expression diagnostics and reference marking (`missingIdentifierInEnumComputedNameNoFlake`, `parserComputedPropertyName16`); generic mapped-type `keyof` with renamed keys simplifies in bare and template-literal positions (`mappedTypeConstraints2`) and recursive indexed access (`mappedTypeAsClauseIntersectionConstraintIndexedAccess`); an import of an ambient module declared in the same file does not probe the filesystem for a package, including in the resolution trace (`ambientModuleImportingItselfNotResolved`); a relative type reference looked up in a type root uses a normalized candidate path, as in the resolution trace of tsgo (`type-root-relative-candidate`); a type reference or relative import whose name is only a drive root (`C:`) uses the candidate `C:/` as in tsgo, without the probe of `C:.d.ts` that panicked when the drive existed (`type-reference-drive-root`, [regression](../crates/tsrs_module/tests/integration/resolver_drive_root_test.rs)); a type reference or module name that ends with a directory separator skips the file lookup in a type root, as tsgo does (`type-root-trailing-separator-name`, `type-root-trailing-separator-module`); a relative import rewritten into a referenced project reports TS2878 when the two projects' root or output directories have different roots, such as drives, as in tsgo ([regression](../crates/tsrs_cli/tests/integration/rewrite_import_cross_drive_reference.rs)); conditional-type simplification caches reading and writing separately, preserving the write-side TS2322 (`simplifiedConditionalTypeWritingCache`); JavaScript JSDoc `@extends` type arguments apply to call, mixin, element-access, parenthesized, and conditional heritage expressions, and incompatible tags name the full heritage expression (`extendsTag7`–`extendsTag14`); mapped types in JavaScript JSDoc `@extends` and `@augments` type arguments match Go without panicking (`jsdoc-heritage-mapped-type`, `jsdoc-heritage-mapped-type-diagnostics`); async generator `yield` operands and `yield*` async iterables with no awaited type report TS1321, TS1062 or TS1322 and infer a `never` yield type without panicking (`async-generator-invalid-thenable-yield`); beside other yields, where pinned tsgo panics, the other yields give the yield type ([regression](../crates/tsrs_cli/tests/integration/async_generator_missing_yield_type.rs)); undefined-property widening caches by symbol identity, preserving the `undefinedPropertyDeclarationOrder` fixture and canonical `objectLiteralNormalization` baselines; a static initializer that assigns a later readonly property through a nested access (`C.self.later = 1`) reports TS2540 without spurious TS7022 circularity errors, as the declaration-order check skips a nested access before it resolves the property's type (`nested-property-access-declaration-order`); top-repository comparisons still report known parity gaps and tsrs failures; 0.20.1 removes a union-constraint shortcut that could miss `NoInfer` constituents (#808) | | Standard library typings | yes | Source 40 imports upstream `lib.dom.d.ts` and `lib.webworker.d.ts` byte for byte, including their expanded CSS, DOM, Serial, and WebTransport declarations; the two upstream type-baseline changes match. `esnext.promise` selects `lib.esnext.promise.d.ts`; `Promise.allKeyed` and `Promise.allSettledKeyed` preserve object keys and awaited value types (`promiseAllKeyed`). Source-phase imports add `lib.esnext.modulesource.d.ts` to the `esnext` aggregate and expose `AbstractModuleSource`. Source 62 adds `lib.esnext.iterator.d.ts` to that aggregate and maps `--lib esnext.iterator` to it, exposing `IteratorObject.chunks`, `join`, and `includes` plus `Iterator.zip` and `zipKeyed`; all six new compiler variants match error, type, symbol, and JavaScript baselines; replacement libraries retain discovery order when they share a priority (`libReplacementOrder`); `es2023.intl` adds `Intl.PluralRules.selectRange` with an `Intl.LDMLPluralRule` result (`intlPluralRulesSelectRangeES2023`). Windows `noembed` executable paths use the existing OS realpath normalization before adjacent-library lookup (`test_noembed_executable_realpath_uses_compiler_path_spelling` and the `npm_lib_path` CLI tests; Windows runtime validation pending). |