Skip to content

Doesn't correctly handle T types. #222

@ToborWinner

Description

@ToborWinner

This code seems to cause issues, I had to manually fix my guard check.

export interface BaseVideo<T extends VideoType = VideoType> {
    type: T;
    data: T extends "MOTIVATIONAL" ? MotivationalVideoData :
        T extends "SHOWER_THOUGHTS" ? ShowerThoughtsVideoData :
        T extends "QUIZ" ? QuizVideoData :
        T extends "QUIZ_SHORT" ? QuizShortVideoData :
        T extends "SUMMARY" ? any : never;
}

(Yes isVideoType is included in the guards, and the other types not included in this code too)

Apart the data part, which is understandable if it gets it wrong, the guard checks if the type is equal to "T" and typescript gives me an error there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions