laters

如何从对象的值提取到一个新的类型别名

  •  
  •   laters · Apr 12, 2023 · 1589 views
    This topic created in 1209 days ago, the information mentioned may be changed or developed.

    How to extract a new type alias from an object's value

    const test = {
    'a': ['music','bbq','shopping'],
    'b': ['move','work']
    };
    

    如何从 test 对象中得到

    type Types = 'music' | 'bbq' | 'shopping' | 'move' | 'work'
    
    1 replies    2023-05-08 15:14:39 +08:00
    zy0829
        1
    zy0829  
       May 8, 2023
    type Types<T> = T[keyof T]
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1195 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 17:45 · PVG 01:45 · LAX 10:45 · JFK 13:45
    ♥ Do have faith in what you're doing.