You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
YAML documents often have a structure with known key types turning into known value types. The current YAMLMap type is based on a Record type which means any key of the input object maps to any value of the input object.
Describe the solution you'd like
Change the template type for YAMLMap from YAMLMap<K = unknown, V = unknown> to YAMLMap<T extends Record<unknown, unknown>> and propagate types, E.g. YAMLMap<T>::get<S extends keyof T>(key: S, keepScalar?: false): T[S]
This will both prevent typos in "get" calls, and remove unnecessary undefined checks if the schema ensures a value is present.
Describe alternatives you've considered
Keep losing type information as I navigate the document
Additional context
Chose this library because of its support for incremental changes to YAML, which will let me modify config files with minimal diffs. This was clearly a lot of hard work to expose this library and I appreciate what you've done so far 😄
The text was updated successfully, but these errors were encountered:
Sounds like a pretty good idea. I'd be happy to consider a PR for this.
Note that the current compiled types are tested to work in TS 3.9 or later; sticking to that is not a hard limit, we can increase the minimum in a minor version update.
Is your feature request related to a problem? Please describe.
YAML documents often have a structure with known key types turning into known value types. The current YAMLMap type is based on a Record type which means any key of the input object maps to any value of the input object.
Describe the solution you'd like
Change the template type for YAMLMap from
YAMLMap<K = unknown, V = unknown>
toYAMLMap<T extends Record<unknown, unknown>>
and propagate types, E.g.YAMLMap<T>::get<S extends keyof T>(key: S, keepScalar?: false): T[S]
This will both prevent typos in "get" calls, and remove unnecessary undefined checks if the schema ensures a value is present.
Describe alternatives you've considered
Keep losing type information as I navigate the document
Additional context
Chose this library because of its support for incremental changes to YAML, which will let me modify config files with minimal diffs. This was clearly a lot of hard work to expose this library and I appreciate what you've done so far 😄
The text was updated successfully, but these errors were encountered: