laters

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

  •  
  •   laters · Apr 12, 2023 · 1836 views
    This topic created in 1331 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
    zy0829
    May 8, 2023
    1
    type Types<T> = T[keyof T]
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4985 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 02:13 · PVG 10:13 · LAX 18:13 · JFK 21:13
    ♥ Do have faith in what you're doing.