Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

[flow] Update typing for idx #854

Merged
merged 1 commit into from
Jul 6, 2023
Merged

[flow] Update typing for idx #854

merged 1 commit into from
Jul 6, 2023

Conversation

SamChou19815
Copy link
Contributor

In this PR, I switched the idx typing from a special cased flow builtin to a userland defined type powered by conditional and mapped type, similar to the TypeScript type definition provided.

Some notes on typing tricks:

  • I used the trick of opaque type to better preserve the type application structure, so that they can be reliably unboxed in the UnboxDeepRequired type.
  • I added the case for function types before interface {}, because function type is a subtype of interface {}...

Notes on the prettier change:

  • We need to update to Prettier 3 to support the new flow syntax.
  • pretty-quick doesn't work on Prettier 3, so I copied some bash script from prettier website instead.

In this PR, I switched the idx typing from a special cased flow builtin to a userland defined type powered by conditional and mapped type, similar to the TypeScript type definition provided.

Some notes on typing tricks:

- I used the trick of opaque type to better preserve the type application structure, so that they can be reliably unboxed in the `UnboxDeepRequired` type.
- I added the case for function types before `interface {}`, because function type is a subtype of `interface {}`...
@yungsters yungsters merged commit 340eb4e into main Jul 6, 2023
@yungsters yungsters deleted the idx-flow-typing branch July 6, 2023 23:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants