How to change type of class property based on value of env

121 Views Asked by At

I have a class

export class FeedItem extends Model {
  tags: process.env.NODE_ENV === 'test' ? string : string[]
}

I would like to set the type of tags as a string if I am running tests otherwise a string array. Currently it gives me an error. How do I achieve this in typescript?

0

There are 0 best solutions below