KouShuiYu

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

  •  
  •   KouShuiYu · Sep 23, 2021 · 1478 views
    This topic created in 1724 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   ·   1071 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 23:05 · PVG 07:05 · LAX 16:05 · JFK 19:05
    ♥ Do have faith in what you're doing.