Open ddeltree opened 6 months ago
In the current state, it is difficult to offer suggestions when the template includes another template.
Think about the following example as a type that represent the path to properties of a document in a database.
type UserId = `user::${number}`;
type MembershipPaths<T> = `membership.${T}.joinedAt` | `membership.${T}.leftAt` | `membership.${T}.invitedBy`;
type Group = {
name: string;
membership: Record<UserId, {
joinedAt: number;
leftAt?: number;
invitedBy: UserId;
}>
};
type GroupPaths = 'name' | MembershipPaths<UserId>;
As you can imagine, in reality the types are actually generated on the fly by passing the document type.
In the case presented here, to provide a suggestion that is valid, one has to find the static part of the template T
, which is not impossible, but requires some work.
Also, using this workaround, once the suggestion is selected, the dev has to remove the fake part of the suggestion.
Currently, if you create a variable of an interpolated string type using either
number
,string
orbigint
inside you'll get no suggestion for it:I think it would be more helpful to provide suggestions for those types of strings, having no apparent reason not to. Especially considering the type annotation could be a generic type, in which case you'd have to hover over the variable in order to be aware of the possible values.