laters

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

  •  
  •   laters · Apr 12, 2023 · 1683 views
    This topic created in 1265 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   ·   Privacy   ·   Solana   ·   4992 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 07:54 · PVG 15:54 · LAX 00:54 · JFK 03:54
    ♥ Do have faith in what you're doing.