You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

tsconfig.json中出现Cannot find global type 'CallableFunction'错误求助

解决"Cannot find global type 'CallableFunction'"错误

错误原因

核心问题是TypeScript版本过低:CallableFunction是TypeScript 3.2及以上版本才引入的全局类型,你当前依赖的typescript为3.1.6,无法识别该类型。之前用NPM时依赖解析机制可能掩盖了版本冲突,改用Yarn后冲突直接暴露。

解决步骤

  1. 升级TypeScript版本
    修改package.json里的typescript依赖版本,替换为与assemblyscript@0.23.1兼容的稳定版本(推荐^4.9.5,适配AssemblyScript 0.23.x系列):

    "devDependencies": {
      "asbuild": "^0.2.0",
      "assemblyscript": "^0.23.1",
      "near-sdk-as": "^3.2.3",
      "typescript": "^4.9.5"
    }
    
  2. 清理Yarn缓存并重装依赖
    执行命令清除旧缓存,避免残留依赖引发异常:

    yarn cache clean
    yarn install
    
  3. 验证tsconfig路径(可选)
    确认tsconfig.json的extends路径正确:若该文件在项目子目录(如assembly/),../node_modules/assemblyscript/std/assembly.json是合理路径;若在根目录,需改为./node_modules/assemblyscript/std/assembly.json。

完成上述操作后重新运行项目,CallableFunction的类型错误即可解决。

内容的提问来源于stack exchange,提问作者jcloud

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 14:41:33