Flow-compatible string object type that does not interfere with auto-completion #1610
refirst11
started this conversation in
Show and tell
Replies: 2 comments
-
|
After exploring other methods, I tested the completion speed. { valueOf(): string }The fastest time recorded was 0.06ms. This was the most concise way to write it compared to other cases such as & {}, Pick, and Record. This is type-compilation compatible with flow-bin. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
👍 I also suggested the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In
StyleXCSSTypes.js, some types include both string literals and the primitivestringtype:In TypeScript and JavaScript (via d.ts), the primitive
stringabsorbs all string literal types in a union, causing autocomplete candidates to disappear entirely.Since
StyleX$CreateusesSas a generic argument type, no actual type checking is performed on values anyway:This means
stringserves only as an index, not a validator. Replacing it withstring & {}would preserve the open-ended nature of the type while restoring autocomplete for the listed literals.I tested and confirmed that
flow-bincannot compile to d.ts.However, since there are currently few cases where actual harm is being caused, I simply wanted to share this as a potential area for improvement.
Beta Was this translation helpful? Give feedback.
All reactions