Reputation: 425
Could use some help figuring out why the type here is
never
or never[]
const effects: EFFECT_TYPES[] = editState === EDITSTATES.EDIT ? currentEffects : draftEffects;
const currentImageUrl = urlFromEffects({
baseURL: imageUrl,
effects,
});
throws
Type 'EFFECT_TYPES[]' is not assignable to type 'never[]'. Type 'EFFECT_TYPES' is not assignable to type 'never'.ts(2322)
Upvotes: 0
Views: 171
Reputation: 2812
The problem is that TypeScript incorrectly inferred the type of effects
to be never
, the remedy being to define the type of effects
manually:
export const urlFromEffects = ({ baseURL, effects = []}: {
baseURL: string;
effects?: EFFECT_TYPES[];
}) => {
// ...
}
Upvotes: 1