TS: type
const a = [1, 2] as const;
type In = (typeof a)[number];
const ab = [{ title: '99' }, { title: '88' }] as const;
type Iab = (typeof ab)[number]['title'];
const abc = {
a: 1,
b: 2
} as const;
type Iabctype = keyof typeof abc;
type Iabc = (typeof abc)[Iabctype];
interface IUser {
id: number;
name: string;
age: number;
}
type UserWithoutId = Omit<IUser, 'id'>;
interface User2 {
id: number;
name: string;
age: number;
email: string;
}
type UserBasicInfo = Pick<User2, 'name' | 'email'>;
function reflect<P extends string | number | boolean, T>(p: P, t: T) {
return [p, t];
}
const p = reflect(false, '99');