You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found a small issue with our typegen. Happened to me working with one of Astro's TS presets, but can happen with anyone using exactOptionalPropertyTypes: true.
Astro: Astro CLI offers different configs of TypeScript, this project was using the "strictest", among some settings there was exactOptionalPropertyTypes: true.
This config treats undefined differently than unset because they behave differently for "prop" in object check, undefined brings a false positive.
Because of that, formatting a records array was yielding incompatible types between what was coming out of my .map and what DBRecord was typed.
a prop: undefined coming in to a .map leaves as unset. But the type definition prop?: 'value' | null doesn't accept it, instead it would have to be prop?: 'value' | null | undefined To Reproduce
Reproducing
Set a TS project with exactOptionalPropertyTypes: true.
💡 Exact reproduction could be setting a brand new Astro project with strictest TS preset.
Generate types via the CLI and fetch a list of records with getPaginated, getAll, or getMany.
Take the record list and go through a records.map(), for example split blog posts per publishing month
The return type of this map would then be { [key:string]: PostRecord[] }
TSC will complain there isn't overload between those types and will suggest adding undefined as a target value too.
Expected behavior
Overload matches.
Software version
package
version
@xata.io/client
^0.21.6
@xata.io/cli
0.11.18
The text was updated successfully, but these errors were encountered:
I found a small issue with our typegen. Happened to me working with one of Astro's TS presets, but can happen with anyone using
exactOptionalPropertyTypes: true
.Astro: Astro CLI offers different configs of TypeScript, this project was using the "strictest", among some settings there was
exactOptionalPropertyTypes: true
.This config treats
undefined
differently thanunset
because they behave differently for"prop" in object
check,undefined
brings a false positive.Because of that, formatting a records array was yielding incompatible types between what was coming out of my
.map
and whatDBRecord
was typed.a
prop: undefined
coming in to a.map
leaves as unset. But the type definitionprop?: 'value' | null
doesn't accept it, instead it would have to beprop?: 'value' | null | undefined
To Reproduce
Reproducing
Set a TS project with
exactOptionalPropertyTypes: true
.getPaginated
,getAll
, orgetMany
.records.map()
, for example split blog posts per publishing month{ [key:string]: PostRecord[] }
undefined
as a target value too.Expected behavior
Overload matches.
Software version
@xata.io/client
^0.21.6
@xata.io/cli
0.11.18
The text was updated successfully, but these errors were encountered: