[英]src/index.ts:12:22 - error TS2307: Cannot find module './schema.graphql' or its corresponding type declarations
hi I want to import a graphql file.嗨,我想导入一个 graphql 文件。 For this i have installed babel-plugin-import-graphql package.but for some reason i am getting error
为此,我安装了 babel-plugin-import-graphql 包。但由于某种原因我收到错误
\node_modules\ts-node\src\index.ts:750
return new TSError(diagnosticText, diagnosticCodes);
^
TSError: ⨯ Unable to compile TypeScript:
src/index.ts:12:22 - error TS2307: Cannot find module './schema.graphql' or its corresponding type declarations.
12 import typeDefs from "./schema.graphql";
~~~~~~~~~~~~~~~~~~
how do i do the import我如何进行导入
import typeDefs from "./schema.graphql";
graphql.d.ts graphql.d.ts
declare module "*.graphql" {
import { DocumentNode } from "graphql";
const value: DocumentNode;
export = value;
}
.babelrc .babelrc
{
"plugins": ["import-graphql"]
}
将文件从
重命名为src/@types/graphql.d.ts
src/@types/index.d.ts
,保持内容不变,然后重新启动 TS 服务器(或者只是重新加载 IDE)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.