Repository navigation
Description
Summary
oxlint --type-aware --type-check reports false TS2322/TS2345 errors on code that both tsc and tsgo --noEmit accept: when a call infers a generic T that also appears in a union with (string & {}) (the common "string with autocomplete" idiom), tsgolint resolves T as string instead of the type inferred from the other arguments.
The practical impact is large: antd's Table uses exactly this idiom (SpecialString<T> = T | (string & {}) in rc-table's DataIndex), so essentially every <Table dataSource={rows} columns={[{ dataIndex: ... }]} /> in an antd codebase reports Type 'Rec[]' is not assignable to type 'readonly string[]', and every record in a column render / rowKey callback resolves as string.
Versions
- oxlint: 1.72.0
- oxlint-tsgolint: 0.24.0
- typescript: 5.9.3 (clean)
- @typescript/native-preview (tsgo): 7.0.0-dev.20260527.2 (clean)
- Platform: Linux x64
Minimal reproduction (zero runtime deps)
src/repro.ts:
interface Column<T> {
dataIndex?: (T | (string & {}))[]
}
declare function table<T>(rows: readonly T[], columns: Column<T>[]): void
declare const rows: { id: number }[]
table(rows, [{ dataIndex: ['id'] }])tsconfig.json:
{
"compilerOptions": {
"strict": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"noEmit": true
},
"include": ["src"]
}package.json devDependencies: [email protected], @typescript/[email protected], [email protected], [email protected].
$ npx tsc --noEmit # exit 0
$ npx tsgo --noEmit # exit 0
$ npx oxlint --type-aware --type-check src/
src/repro.ts:9:7: error typescript(TS2345): Argument of type '{ id: number; }[]' is not assignable to parameter of type 'readonly string[]'.Expected: no diagnostics (match tsc/tsgo — T infers as { id: number } from rows; 'id' matches the (string & {}) union member).
Actual: T is resolved as string, producing the TS2345 above.
Bisection notes, in case they help locate it:
- Replacing
(string & {})with plainstringin the union → no divergence (clean everywhere). - Moving the union out of the object property into a direct parameter (
keys: (T | (string & {}))[]) → no divergence. The union seems to need to sit behind an object-literal property for the bad candidate to win.
Real-world shape (antd Table)
With [email protected], [email protected], @types/[email protected], jsx: react-jsx:
import { Table } from 'antd'
type Rec = { alert: { id: string; name: string } }
const rows: Rec[] = [{ alert: { id: '1', name: 'a' } }]
export function App() {
return (
<Table
dataSource={rows}
rowKey={(record) => record.alert.id}
columns={[
{
title: 'Name',
dataIndex: ['alert', 'name'],
key: 'name',
render: (_, record) => record.alert.name,
},
]}
/>
)
}tsc / tsgo: clean. oxlint --type-aware --type-check:
src/App.tsx:9:7: error typescript(TS2322): Type 'Rec[]' is not assignable to type 'readonly string[]'.
src/App.tsx:10:34: error typescript(TS2339): Property 'alert' does not exist on type 'string'.
src/App.tsx:16:41: error typescript(TS2339): Property 'alert' does not exist on type 'string'.
The string comes in through rc-table's DataIndex<T>, whose union includes SpecialString<T> = T | (string & {}). Same result when the table is wrapped with styled-components (styled(Table)\...` as typeof Table), which is how we first hit it. Related to (but distinct from) the fixed #706/#864 — there the generic collapsed to any; here it resolves to string`, on 0.24.0.
Additional observation: tsconfig exclude not honored
While reducing this I noticed --type-check also type-checks files the tsconfig excludes. Adding to the repro:
src/excluded.e2e.ts:
import { thing } from 'not-a-real-module'
export const x: number = thingand "exclude": ["**/*.e2e.ts"] in the tsconfig. tsc/tsgo skip the file; oxlint reports:
src/excluded.e2e.ts:1:23: error typescript(TS2307): Cannot find module 'not-a-real-module' or its corresponding type declarations.
Happy to split that into a separate issue if you prefer.
Activity
camc314 commentedon Jul 7, 2026
Thanks for the detailed report. This is an upstream
typescript-goinference regression rather than a TSGolint configuration issue. It reproduces with TSGolint’s pinnedtsgoand current upstream.Please follow:
stripSearchParamsrejected (TS2322), clean in tsc + 20260623.1 microsoft/typescript-go#4462We’ll pick up the upstream fix once
typescript-gohas fixed this issue.Thanks!
[-]Generic inferred as `string` when a union member is `T | (string & {})`: false TS2322/TS2345, diverges from tsc/tsgo (breaks antd Table)[/-][+]Generic inferred as `string` when a union member is `T | (string & {})`: false TS2322/TS2345 (breaks antd Table)[/+]camc314 commentedon Jul 16, 2026
This is expected behaviour, if you don't want the file to be linted, add it to your ignore patterns.
camc314 commentedon Aug 3, 2026
fixed by microsoft/typescript-go@90b40e8