Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find a declaration file for module './vue-apollo' #278

Closed
sneko opened this issue May 10, 2018 · 5 comments
Closed

Could not find a declaration file for module './vue-apollo' #278

sneko opened this issue May 10, 2018 · 5 comments

Comments

@sneko
Copy link

sneko commented May 10, 2018

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 😃 ?

@leovanhaaren
Copy link

It's because the vue-apollo file probably isn't a .ts file but a .js file. (and noExplicitAny is enabled)

@sneko
Copy link
Author

sneko commented May 10, 2018

@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 😢

@sneko
Copy link
Author

sneko commented May 10, 2018

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

@sneko sneko closed this as completed May 10, 2018
@maksnester
Copy link

maksnester commented Jan 5, 2019

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,

@jfcieslak
Copy link

{
	"compilerOptions": {
		//...
		"types": [
			"vue-cli-plugin-apollo/types"
		],
	},
}

Try adding the types in your compiler options, this should do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants