V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
KouShuiYu

不太熟悉 TypeScript, 这种问题怎么优雅的解决? 提示:不能调用可能是“未定义”的对象。ts(2722)

  •  
  •   KouShuiYu · Sep 23, 2021 · 1407 views
    This topic created in 1682 days ago, the information mentioned may be changed or developed.
    const checkCustom = (rule:rule, value: unknown) => {
      const { custom } = rule;
      if (toRawType(custom) !== 'Function') {
        throw new Error('custom need function type values');
      }
      return custom(rule, value);
    };
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2438 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:34 · PVG 23:34 · LAX 08:34 · JFK 11:34
    ♥ Do have faith in what you're doing.