KouShuiYu

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

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