I define an AbstractModel
like so:
export interface AbstractModel {
[key: string]: any
}
Then I declare the type Keys
:
export type Keys = keyof AbstractModel;
I would expect that anything with the Keys type would be interpreted univocally as a string, for example:
const test: Keys;
test.toLowercase(); // Error: Property 'toLowerCase' does not exist on type 'string | number'. Property 'toLowerCase' does not exist on type 'number'.
Is this a bug of Typescript (2.9.2), or am I missing something?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…