Issue
I have this type
type Abc = 'a' | 'b' | 'c'
how can I make myObj.something
type Abc
?
I can think of valueOf:
const myObj = {
something: ['a', 'b', 'c'] as valueOf Abc
}
but I wonder why it doesn't work
Solution
in your case you are trying to set ['a', 'b', 'c']
(which is an array) as Abc
. You should define myObj.something as an array of type Abc
, with Abc[]
const myObj = {
something: ['a', 'b', 'c'] as Abc[]
}
Answered By - Likor
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.