首页 > 解决方案 > 尝试在使用打字稿做出本机反应时导入 gql 文件错误 2307

问题描述

在代码中,导入显示错误“找不到模块'./somefile.gql'或其相应的类型声明.ts(2307)”,但我实际上可以在设备中运行该应用程序

问题来了,因为我想提交并且 husky(预提交挂钩)捕获错误并且无法部署代码

更新:.babelrc 中已经有插件“babel-plugin-import-graphql”,我想这就是它构建良好的原因,husky 运行 tsc 并因此捕获错误

import {
  getWorkspaces as GET_WORKSPACES,
  getCurrentWorkspace as GET_WORKSPACE,
} from '../../graphql/queries/workspaces.gql';

错误说

Cannot find module '../../graphql/queries/workspaces.gql' or its corresponding type declarations.ts(2307)

标签: typescriptreact-nativegraphql

解决方案


推荐阅读