我正在使用@ nuxtjs / apollo包和打字稿创建一个nuxt项目。我想将apollo的配置添加到我的nuxt.config.ts中,但不会显示所有可用的属性。
配置应该可以具有以下选项,但是它说:“'wsEndpoint'在'ApolloClientConfig'类型中不存在”:
import { Configuration } from '@nuxt/types';
const configuration: Configuration = {
apollo: {
clientConfigs: {
default: {
httpEndpoint: process.env.VUE_APP_ALERTS_COMMENTS_API_HTTP_URL,
wsEndpoint: process.env.VUE_APP_ALERTS_COMMENTS_API_WS_URL,
websocketsOnly: false,
}
}
}
}
这是我的tsconfig.json:
{
"compilerOptions": {
"experimentalDecorators": true,
"target": "es2018",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom"
],
"esModuleInterop": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@types/node",
"@nuxt/types",
"@nuxtjs/apollo/types/nuxt.d.ts",
"vue-cli-plugin-apollo",
"@types/jest",
"vue-toasted/types",
"vue-i18n/types"
]
},
"exclude": [
"node_modules",
"e2e",
"./env.config.ts"
],
"files": [
"custom.d.ts"
]
}
我对类型进行了一些研究:
我还尝试将tsconfig.json中的“ vue-cli-plugin-apollo”替换为:“ vue-cli-plugin-apollo / types.d.ts”,结果没有差异。
这里是nuxt.d.ts和types.d.ts from "vue-cli-plugin-apollo"。
这是我package.json的相关部分
{
...
"dependencies": {
...
"@nuxtjs/apollo": "^4.0.0-rc19",
"nuxt": "^2.0.0",
...
},
"devDependencies": {
...
"vue-cli-plugin-apollo": "^0.21.3",
...
},
...
}