V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
myCupOfTea
V2EX  ›  程序员

typeScript 4.1 将支持 Template string types

  •  1
     
  •   myCupOfTea · Sep 1, 2020 · 2992 views
    This topic created in 2076 days ago, the information mentioned may be changed or developed.

    终于可以方便的给 dva 的 dispatch 写类型声明.呜呜

    https://github.com/microsoft/TypeScript/pull/40336

    type TempStr<T extends string> = `test${T}`
    type SuffixStr = "abc"
    const str : TempStr<SuffixStr> = "testabc";
    

    可以这样写声明了 好期待什么时候正式发布 4.1

    3 replies    2020-09-02 09:43:57 +08:00
    doublelam
        1
    doublelam  
       Sep 1, 2020
    哇,期待期待,很早就想有这种方式写类型了,要是支持正则就更好了
    myCupOfTea
        2
    myCupOfTea  
    OP
       Sep 2, 2020
    @doublelam 感觉以后会支持..
    yuanfnadi
        3
    yuanfnadi  
       Sep 2, 2020
    我用 dva-model-creator
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1199 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 23:54 · PVG 07:54 · LAX 16:54 · JFK 19:54
    ♥ Do have faith in what you're doing.