ts-simple-type
ts-simple-type copied to clipboard
Feature request: when a type parameter extends a type, it should be treated as that type
Consider this code:
function foo<T extends string>(name: T) {
return html`<input .value=${name}>`;
}
In the TS type system, name is assignable to a string, because it must be a subtype of string. Currently it looks like type parameters are treated as unknown
Workaround:
function foo<T extends string>(name: T) {
const nameStr: string = name;
return html`<input .value=${nameStr}>`;
}
This leverages the TS type system to convert from T to string in a type safe way, so that by the time it reaches lit-analyzer, it's clearly a string.