KouShuiYu

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

  •  
  •   KouShuiYu · Sep 23, 2021 · 1476 views
    This topic created in 1721 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   ·   5933 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 02:08 · PVG 10:08 · LAX 19:08 · JFK 22:08
    ♥ Do have faith in what you're doing.