Skip to content

Supporting exactOptionalPropertyTypes #498

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

Merged
merged 1 commit into from
Jul 12, 2023
Merged

Supporting exactOptionalPropertyTypes #498

merged 1 commit into from
Jul 12, 2023

Conversation

seivan
Copy link
Contributor

@seivan seivan commented Feb 28, 2023

signal key has defined its key as optional, not necessarily the value even though this happens implicitly. No key means no value which translates to undefined:

    signal?: AbortSignal | null;

To support exactOptionalPropertyTypes it would have to be defined as:

    signal?: AbortSignal | null | undefined;

While you could say the key isn't optional (removing ?), which then requires an explicit undefined value:

    signal: AbortSignal | null | undefined;

That would require an explicit undefined being passed, which might break existing implementations, but also, it can't be changed here.

Given this key is part of TS definitions and module augmentation is overkill, just "oring" from undefined to an expected value (in this case null) solves the problem.

Replacing: #457

`signal` key has defined its key as optional, not necessarily the value even though this happens implicitly. No key means no value which translates to `undefined`:
```ts
    signal?: AbortSignal | null;
```

To support exactOptionalPropertyTypes it would have to be defined as:
```ts
    signal?: AbortSignal | null | undefined;
```

While you could say the key isn't optional (removing ?), which then requires an explicit undefined value:
```ts
    signal: AbortSignal | null | undefined;
```
That would require an explicit undefined being passed.

Given this key is part of TS definitions and module augmentation is overkill, just "oring" from undefined to an expected value (in this case null) solves the problem.

Replacing: #457
@js2me
Copy link
Member

js2me commented Jul 12, 2023

@seivan thanks!

@js2me js2me merged commit 79c007d into acacode:next Jul 12, 2023
@seivan seivan deleted the patch-2 branch September 14, 2023 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants