首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >阿波罗-服务器-快件、阿波罗-服务器和阿波罗-缓存-控制中的TypeScript导入问题

阿波罗-服务器-快件、阿波罗-服务器和阿波罗-缓存-控制中的TypeScript导入问题
EN

Stack Overflow用户
提问于 2020-10-22 02:47:19
回答 2查看 2.2K关注 0票数 2

我试图在类型记录中从“"apollo-server-express":阿波罗服务器”:"^2.9.4"和"^2.9.4“升级到2.12.0版本,在应用程序的构建过程中,我得到了下面的错误:

node_modules/apollo-server-express/node_modules/apollo-server-core/dist/plugin/index.d.ts:1:13

错误TS1005:'=‘预期。

1从“阿波罗-服务器-插件基”导入类型{ ApolloServerPlugin };

我还没有找到解决这个问题的方法,我已经删除了node_modules文件夹和package-lock.json,但仍然无法工作。

有帮手是很好的.

代码语言:javascript
复制
tsconfig.json


{
  "compilerOptions": {
    "target": "es5",
    "moduleResolution": "node",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "outDir": "./dist",
    "declaration": true
  },
  "include": [
    "src/**/*"
  ],
  "exclude": [
    "node_modules",
    "**/*.spec.ts",
    "**/*.test.ts"

  ]

}
代码语言:javascript
复制
package.json

"dependencies": {
    "@apollo/federation": "^0.10.2",
    "@types/bluebird": "^3.5.27",
    "@types/cookie-parser": "^1.4.2",
    "@types/jest": "^24.0.19",
    "@types/mysql": "^2.15.7",
    "@types/nanoid": "^2.0.0",
    "@types/node": "^14.10.1",
    "@types/umzug": "^2.2.2",
    "@types/validator": "^10.11.3",
    "apollo-cache-control": "^0.10.0",
    "apollo-cache-inmemory": "^1.6.6",
    "apollo-client": "^2.6.4",
    "apollo-datasource-rest": "^0.6.1",
    "apollo-link": "^1.2.12",
    "apollo-link-context": "^1.0.20",
    "apollo-link-http": "^1.5.17",
    "apollo-link-rest": "^0.7.3",
    "apollo-link-schema": "^1.2.3",
    "apollo-server": "^2.12.0",
    "apollo-server-express": "^2.12.0",
    "apollo-server-plugin-response-cache": "^0.3.1",
    "apollo-server-testing": "^2.9.0",
    "axios": "^0.19.2",
    "cookie-parser": "^1.4.4",
    "cron": "^1.7.2",
    "elastic-apm-node": "^3.3.0",
    "express": "^4.17.1",
    "express-graphql": "^0.9.0",
    "graphql": "^14.5.8",
    "graphql-import": "^0.7.1",
    "graphql-schema-linter": "^0.2.1",
    "jsonwebtoken": "^8.5.1",
    "jwk-to-pem": "^2.0.3",
    "kafka-node": "^4.1.3",
    "link": "^0.1.5",
    "log4js": "^5.0.0",
    "mysql2": "^1.7.0",
    "nanoid": "^3.1.7",
    "node": "^14.5.0",
    "node-cache": "^5.1.1",
    "node-fetch": "^2.6.0",
    "promise-retry": "^1.1.1",
    "rimraf": "^3.0.0",
    "save": "^2.4.0",
    "sequelize": "^5.19.5",
    "sequelize-cli": "^5.5.1",
    "soap": "^0.30.0",
    "ts-jest": "^24.1.0",
    "typescript": "^3.6.3",
    "umzug": "^2.2.0"
  },
  "devDependencies": {
    "@types/graphql": "^14.5.0",
    "graphql-tag": "^2.10.1",
    "graphql-tools": "^4.0.5",
    "jest": "^24.8.0",
    "jest-cli": "^24.8.0"
  },
  "jest": {
    "testEnvironment": "node",
    "testPathIgnorePatterns": [
      "/node_modules/",
      "/dist/"
    ],
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-10-28 11:53:32

阿波罗服务器核心中使用的import type语法不受您正在使用的类型记录版本(v3.6)的支持。这个语法从v3.8开始就可用了。https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export

更新类型记录,错误将消失。

票数 3
EN

Stack Overflow用户

发布于 2021-02-11 08:00:58

我也遇到了同样的错误,我在lib模块目标中尝试了tsconfig.json文件中的不同值,但它们都没有起作用,我从来不想更改node_modules文件,但最后我不得不(悲伤的微笑),更改了index.d.ts文件

import type { DocumentNode } from 'graphql/language/ast';

import { DocumentNode } from 'graphql/language/ast';

同样,tsconfig.json中lib中的这个值也帮助了

"lib": ["es6", "dom", "esnext", "esnext.asynciterable"],

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64474508

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档