TS 4.4: `exactOptionalPropertyTypes: true` support
nstepien opened this issue · comments
Nicolas Stepien commented
TypeScript 4.4's release is around the corner, and I'm testing it right now.
I'm hitting issues with csstype
as properties are optional but do not explicitly allow undefined
, for example
left?: Property.Left<TLength>;
should be
left?: Property.Left<TLength> | undefined;
https://devblogs.microsoft.com/typescript/announcing-typescript-4-4-rc/
Support for this would be nice.
For reference: adazzle/react-data-grid#2566
Fredrik Nicol commented
My first thought was that maybe it would be expected to fail so you're notified when something can be removed. But I guess you're right. This would be annoying:
let myColor: string | undefined;
if (someCondition) {
myColor: 'red';
}
const style: CSS.Properties = {
color: myColor, // Guess this would cause a type error?
}
Nicolas Stepien commented
Yes that's right.
You can also end up with code that looks like this
const style: CSS.Properties = {
color: records[key], // possibly undefined
background: [].find(() => false) // possibly undefined
}
Nicolas Stepien commented
Daniele Orlando commented
Waiting for TS 4.4 support too.
Fredrik Nicol commented
Released in 3.0.10