I wrote this simple function:
function propertyMap<T extends string>(prop:T) { return function<U extends {[key:T]:V},V>(record:U):V { return record[prop]; }; }; And the compiler is giving me the following errors:
error TS1023: An index signature parameter type must be 'string' or 'number'. 3 return function<U extends {[key:T]:V},V>(record:U):V ~~~ error TS2536: Type 'T' cannot be used to index type 'U'. 5 return record[prop]; ~~~~~~~~~~~~ Why is this a limitation?
https://stackoverflow.com/questions/65557167/why-cant-an-index-signature-parameter-type-extend-string-or-number January 04, 2021 at 10:59AM
没有评论:
发表评论