Hi,
I don't understand why but when I'm trying to serve the project I get:
ERROR in E:/meta-front/app/src/main.ts
6:32 Could not find a declaration file for module './vue-apollo'. 'E:/meta-front/app/src/vue-apollo.js' implicitly has an 'any' type.
4 | import store from './store';
5 | import './registerServiceWorker';
> 6 | import { apolloProvider } from './vue-apollo'
| ^
7 |
8 | Vue.config.productionTip = false;
9 |
Version: typescript 2.8.3, tslint 5.10.0
That's really weird since you add TypeScript support in Decembrer #160 and that I checked types were ./node_modules/vue-apollo/types/
Do you have any idea to help me please 馃槂 ?
It's because the vue-apollo file probably isn't a .ts file but a .js file. (and noExplicitAny is enabled)
@leovanhaaren I don't understand, what do am I supposed to do?
I tried to set "no-explicit-any" to false/true but it doesn't change anything 馃槩
It was on my side, because of ./vue-apollo has been generated in JavaScript.
To avoid the issue I just replace it by the standard require():
const apolloProvider = require('./vue-apollo');
// import { apolloProvider } from './vue-apollo'
I also tried to convert apollo.js and vue-apollo.js into .ts files but several of their dependencies were not exporting the types declarations so it was much easier to just use require().
Thanks
I have this issue during usage of vue ui cli tool. I just built generic vue app based on TS and then installed vue-cli-plugin-apollo -> build failed with the mentioned error.
$ vue --version
3.2.2
vue config
module.exports = {
lintOnSave: false,
pluginOptions: {
apollo: {
enableMocks: true,
enableEngine: true
}
}
}
default tsconfig
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env",
"jest"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}
Generated dependencies:
"dependencies": {
"graphql-type-json": "^0.2.1",
"lowdb": "^1.0.0",
"mkdirp": "^0.5.1",
"shortid": "^2.2.8",
"vue": "^2.5.21",
"vue-apollo": "^3.0.0-beta.11",
"vue-class-component": "^6.0.0",
"vue-property-decorator": "^7.0.0",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
},
"devDependencies": {
"@types/jest": "^23.1.4",
"@vue/cli-plugin-babel": "^3.2.0",
"@vue/cli-plugin-e2e-nightwatch": "^3.2.0",
"@vue/cli-plugin-typescript": "^3.2.0",
"@vue/cli-plugin-unit-jest": "^3.2.0",
"@vue/cli-service": "^3.2.0",
"@vue/test-utils": "^1.0.0-beta.20",
"babel-core": "7.0.0-bridge.0",
"graphql-tag": "^2.9.0",
"lint-staged": "^8.1.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"ts-jest": "^23.0.0",
"typescript": "^3.0.0",
"vue-cli-plugin-apollo": "^0.19.1",
"vue-template-compiler": "^2.5.21"
},
Works only with these both settings in ts config:
"allowJs": true,
"strict": false,
{
"compilerOptions": {
//...
"types": [
"vue-cli-plugin-apollo/types"
],
},
}
Try adding the types in your compiler options, this should do.
Most helpful comment
It was on my side, because of
./vue-apollohas been generated in JavaScript.To avoid the issue I just replace it by the standard require():
I also tried to convert
apollo.jsandvue-apollo.jsinto .ts files but several of their dependencies were not exporting the types declarations so it was much easier to just use require().Thanks