Replies: 1 comment
-
This has to do with the way TypeScript handles homomorphic mapped types. Check out @jfet97's excellent article on that subject if you're interested in learning more. Unfortunately there's little that we can do externally to control that. You could open an issue in TS, but what "should" happen here is quite ambiguous in the general case. I'd guess the best way to preserve the association is by using either the fluent or tuple syntax for optional properties. Keep in mind this isn't something I test for extensively as there's little I can do to control it, but if you're getting the behavior you want for required properties, I'd expect this to work similarly: https://arktype.io/docs/objects#properties-optional const numberArray = type("number[]")
const myObject = type({
fluentOptional: numberArray.optional(),
builtinFluentOptional: type.number.array().optional(),
tupleOptional: ["number[]", "?"]
}) |
Beta Was this translation helpful? Give feedback.
-
Code navigation makes a huge impact on developer productivity, so this is an important topic IMO.
Go to Definition
no longer works after implementing ArkType (as pointed out in #688); however, I've found thatGo to Implementation
does almost whatGo to Definition
used to do before implementing ArkType. It's not as convenient as a simple cmd+click, but IMO it is good enough to not be a dealbreaker except......in the cases where the key is set to be optional (e.g.
type({'asdf?': 'string'})
). In these cases it tries to match on a property named"asdf?"
instead of"asdf"
so it results in zero matches.Method discovery still works, but any comments written above a property are no longer displayed with the popup.
How do you all deal with this? Do you just accept that code navigation/hinting will be worse/slower? Or is there a solution to these issues that I'm not aware of?
Beta Was this translation helpful? Give feedback.
All reactions