Note that for the "same" object literal layout, tsc & tsgo report consistent typing diagnostic on TS2322, but they deviate on TS2741.
Steps to reproduce
- Start a plain new project
- "@typescript/native-preview": "7.0.0-dev.20260605.1",
- "typescript": "6.0.3"
- Run
npx tsgo --init to get the default tsconfig. Turn on these flags as well.
- "allowJs": true,
- "checkJs": true,
- "stableTypeOrdering": true,
- Add
src/main.js. Run npx tsc --noEmit & npx tsgo --noEmit to see the difference.
// src/main.js
export let foo = [{
list: [
{ x: 0, y: 0 }
],
missing: null,
}];
export let bar = [{
list: [
{ x: 3, y: 4 },
{ x: 5, y: 12 },
],
}];
foo = bar;
foo = [{
list: [
{ x: 3, y: 4 },
{ x: 5, y: 12 },
],
}];
Behavior with typescript@6.0
src/main.js:16:1 - error TS2322: Type '{ list: { x: number; y: number; }[]; }[]' is not assignable to type '{ list: { x: number; y: number; }[]; missing: null; }[]'.
Property 'missing' is missing in type '{ list: { x: number; y: number; }[]; }' but required in type '{ list: { x: number; y: number; }[]; missing: null; }'.
16 foo = bar;
~~~
src/main.js:6:5
6 missing: null,
~~~~~~~~~~~~~
'missing' is declared here.
src/main.js:18:8 - error TS2741: Property 'missing' is missing in type '{ list: { x: number; y: number; }[]; }' but required in type '{ list: { x: number; y: number; }[]; missing: null; }'.
18 foo = [{
~
19 list: [
~~~~~~~~~~~
...
22 ],
~~~~~~
23 }];
~
src/main.js:6:5
6 missing: null,
~~~~~~~~~~~~~
'missing' is declared here.
Found 2 errors in the same file, starting at: src/main.js:16
Behavior with tsgo
src/main.js:16:1 - error TS2322: Type '{ list: { x: number; y: number; }[]; }[]' is not assignable to type '{ list: { x: number; y: number; }[]; missing: null; }[]'.
Property 'missing' is missing in type '{ list: { x: number; y: number; }[]; }' but required in type '{ list: { x: number; y: number; }[]; missing: null; }'.
16 foo = bar;
~~~
src/main.js:6:5 - 'missing' is declared here.
6 missing: null,
~~~~~~~~~~~~~
src/main.js:18:8 - error TS2741: Property 'missing' is missing in type '{ list: [{ x: number; y: number; }, { x: number; y: number; }]; }' but required in type '{ list: { x: number; y: number; }[]; missing: null; }'.
18 foo = [{
~
19 list: [
~~~~~~~~~~~
...
22 ],
~~~~~~
23 }];
~
src/main.js:6:5 - 'missing' is declared here.
6 missing: null,
~~~~~~~~~~~~~
Found 2 errors in the same file, starting at: src/main.js:16
The diagnostic deviation happens on this line.
-src/main.js(18,8): error TS2741: Property 'missing' is missing in type '{ list: { x: number; y: number; }[]; }' but required in type '{ list: { x: number; y: number; }[]; missing: null; }'.
+src/main.js(18,8): error TS2741: Property 'missing' is missing in type '{ list: [{ x: number; y: number; }, { x: number; y: number; }]; }' but required in type '{ list: { x: number; y: number; }[]; missing: null; }'.
Note that for the "same" object literal layout, tsc & tsgo report consistent typing diagnostic on TS2322, but they deviate on TS2741.
Steps to reproduce
npx tsgo --initto get the default tsconfig. Turn on these flags as well.src/main.js. Runnpx tsc --noEmit&npx tsgo --noEmitto see the difference.Behavior with
typescript@6.0Behavior with
tsgoThe diagnostic deviation happens on this line.