I have an interface
that looks like that:
interface Person {
name: string;
age: number;
group: Options
}
and an enum
that looks like this:
export enum Options {
ONE = 'one',
TWO = 'two',
THREE = 'three',
}
I want to create a new object where the key will be one of the Options
and the value will be Person
.
I tried something like that:
type PersonMapped = {
[key in Options]: Person; // error on the in keyword
}
But I get an error that says: parsing error: Unexpected token, expected "]"
.
What's wrong with this code?
Edit 1: Here's the code example that I try to use:
export enum Group {
ONE = 1,
TWO = 2,
THREE = 3
}
export type Mappable = {
[key in Group]: string
}
Here's the error from the ide:
Edit 2:
It seems that the problem is with my editor settings. I'm using vscode
version - 1.59.1. I also have eslint
extension installed with version - 2.1.23.