Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable exactOptionalPropertyTypes in TypeScript #855

Open
tsa96 opened this issue Oct 15, 2023 · 0 comments
Open

Enable exactOptionalPropertyTypes in TypeScript #855

tsa96 opened this issue Oct 15, 2023 · 0 comments
Labels
For: Backend This is something to do for the backend (server folder) of the website. Priority: Medium Something that should be tried to be done in this release, but not as important as High priority. Size: Small Something that may take a day at most to do. Type: Dev/Internal Something that is more internal to development than end user facing.

Comments

@tsa96
Copy link
Member

tsa96 commented Oct 15, 2023

This is a sensible flag that helps TS distinguish between fields that can be omitted and fields that can take a value of undefined. Enabling it stops you being able to set e.g. k?: string to undefined, and makes TypeScript's type inference when using index signatures a lot stronger - see microsoft/TypeScript#43947

For us, it allows us to make nested interfaces containing optional values using extends JsonObject from type-fest, currently it just spews out errors about not being able to assign to some (e.g. string) index type, see sindresorhus/type-fest#471 (comment) for details.

TypeScript unfortunately doesn't have it on by default or in strict mode, but I'd definitely like to support it. I would add it right now, but it requires --strictNullChecks. So, once we finish #792, this is a freebie.

I have to do a bunch of ugly as unknown as MapZones casts at the moment because of it, leaving comments everywhere that I am referencing this issue number. Once we tackle this, search for every instance and remove.

@tsa96 tsa96 added Size: Small Something that may take a day at most to do. Priority: Medium Something that should be tried to be done in this release, but not as important as High priority. Type: Dev/Internal Something that is more internal to development than end user facing. For: Backend This is something to do for the backend (server folder) of the website. labels Oct 15, 2023
tsa96 added a commit that referenced this issue Nov 2, 2023
This is making me a bit upset. I *think* we should be able ot just enable "exactOptionalPropertyTypes": true
in constants/ to resolve #855 but can't get it to pass cmopile, notsure nx build backend is even using
tsconfig right. Idk I just can't be bothered right now. Good luck!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For: Backend This is something to do for the backend (server folder) of the website. Priority: Medium Something that should be tried to be done in this release, but not as important as High priority. Size: Small Something that may take a day at most to do. Type: Dev/Internal Something that is more internal to development than end user facing.
Projects
None yet
Development

No branches or pull requests

1 participant