Vetur: Object is of type 'unknown' according to Vetur but TypeScript is able to infer the correct type + vue-cli-service build fails.

Created on 24 Apr 2020  路  5Comments  路  Source: vuejs/vetur

  • [X] I have searched through existing issues
  • [X] I have read through docs
  • [X] I have read FAQ

Info

  • Platform: Windows 10 64bit Pro
  • Vetur version: 0.24.0
  • VS Code version: 1.44.2

Problem

Vetur is reporting the parameter is of type unknown even though TypeScript is able to derive the type GetLoggedInUserQuery.

image

Edit:
Cannot build the app because of this.

Reproducible Case

  1. Setup @vue/composition-api for Vue 2
  2. Setup @vue/apollo-composable
  3. Use the useResult() helper of @vue/apollo-composable on your GraphQL query.
  4. Use the parameter (data from the screenshot) of the function from the third argument of the useResult() function.
  5. Vetur will report:

Object is of type "unknown".

Even though TypeScript is able to derive the correct type.

bug typescript

Most helpful comment

@octref Sure, here

All 5 comments

Can you push a minimal repro sample to GitHub so I can clone and find the issue?

@octref Sure, here

Any temporary workaround for this?

@octref Sure, here

I can't reproduce it.
鎴湒 2020-08-05 涓嬪崍1 49 53
Can you give me information when you hover useResult?

The vue-cli-service isn't vetur problem,
but I also study about it.

  1. You're missing two libraries (apollo-client graphql) in this repos.
  2. useGetLoggedInUserQuery have a type error.
  3. The @vue/apollo-composable library have a type error.

Maybe third problem is type problem in @vue/apollo-composable library,
You can skipLibCheck: true in tsconfig.json for ignore it.

I fixed them, and then the project will build success.

Was this page helpful?
0 / 5 - 0 ratings