Hi,
Thanks for the types. I was looking for a type-safe version of lodash.get
with string paths, and Get
solves my problem greatly.
Is it possible to get a compile error if the wrong path is provided?
Example
interface Person {
name: string;
address: {
street: string;
no: number;
};
}
const get = <BaseType, Path extends string>(object: BaseType, path: Path): Get<BaseType, Path> =>
lodash.get(object, path);
const person: Person = { name: "Jane", address: { street: "Abbleton", no: 12 } };
const street = get(person, "address.street"); // Works like a charm.
const unknown = get(person, "address.xyz"); // Is it possible to get an error with this?
Many thanks again,
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too