yxcoder

typescript 类型断言问题

  •  
  •   yxcoder · Nov 6, 2023 · 1835 views
    This topic created in 919 days ago, the information mentioned may be changed or developed.

    type TYPE1 {...}

    type TYPE2 {...}

    type TYPE3 {...}

    type TYPE4 {...}

    type ALL = TYPE1 | TYPE2 | TYPE3 | TYPE4

    问: task 是 TYPE1 | TYPE2 | TYPE3 类型应该怎么表示?(排除 TYPE2 ),这里 ALL 可能有很多种类型,所以不想重新写一遍

    2 replies    2023-11-06 22:04:19 +08:00
    bi531334444
        1
    bi531334444  
       Nov 6, 2023
    Exclude
    Zhuzhuchenyan
        2
    Zhuzhuchenyan  
       Nov 6, 2023
    type A = {a: string};
    type B = {b: string};
    type C = {c: string};
    type D = {d: string};

    type All = A | B | C | D;
    type AllButD = Exclude<All, D>;
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   997 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 75ms · UTC 19:13 · PVG 03:13 · LAX 12:13 · JFK 15:13
    ♥ Do have faith in what you're doing.