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

fix(ExtractComputedReturns): use explicit Record type #1195

Closed
wants to merge 1 commit into from

Conversation

frangio
Copy link

@frangio frangio commented May 17, 2020

This PR fixes the following errors I was seeing.

app/client/node_modules/@vue/runtime-core/dist/runtime-core.d.ts:437:20 - error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'.
  Type 'Function' provides no match for the signature '(...args: any): any'.

437     } ? ReturnType<T[key]['get']> : ReturnType<T[key]>;
                       ~~~~~~~~~~~~~

app/client/node_modules/@vue/runtime-core/dist/runtime-core.d.ts:437:48 - error TS2344: Type 'T[key]' does not satisfy the constraint '(...args: any) => any'.
  Type 'T[keyof T]' is not assignable to type '(...args: any) => any'.
    Type 'T[string] | T[number] | T[symbol]' is not assignable to type '(...args: any) => any'.
      Type 'T[string]' is not assignable to type '(...args: any) => any'.

437     } ? ReturnType<T[key]['get']> : ReturnType<T[key]>;
                                                   ~~~~~~

@pikax
Copy link
Member

pikax commented May 18, 2020

Can you provide how to reproduce the error that you were seeing?

Can you add a test on the test-dts folder?

@yyx990803 yyx990803 added the need test The PR has missing test cases. label May 18, 2020
@frangio
Copy link
Author

frangio commented May 23, 2020

npm init -y
npm install vue@next typescript

tsconfig.json:

{
  "compilerOptions": {
    "target": "es2020",
    "module": "commonjs"
  }
}

index.ts:

import 'vue';

Compile with npx tsc.


Also in the TypeScript playground pasting the existing definition of ExtractComputedReturns.

Playground Link

@frangio
Copy link
Author

frangio commented May 23, 2020

I'm not really sure what test I should add. This type is an internal utility so it's not exported from the index file.

@runkids
Copy link

runkids commented May 25, 2020

When i run script

tsc --target ESNext --module ES6 --outDir esm

I was seeing this error too.

> tsc --target ESNext --module ES6 --outDir esm

node_modules/@vue/runtime-core/dist/runtime-core.d.ts:437:20 - error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'.
  Type 'Function' provides no match for the signature '(...args: any): any'.

437     } ? ReturnType<T[key]['get']> : ReturnType<T[key]>;
                       ~~~~~~~~~~~~~

node_modules/@vue/runtime-core/dist/runtime-core.d.ts:437:48 - error TS2344: Type 'T[key]' does not satisfy the constraint '(...args: any) => any'.
  Type 'T[keyof T]' is not assignable to type '(...args: any) => any'.
    Type 'T[string] | T[number] | T[symbol]' is not assignable to type '(...args: any) => any'.
      Type 'T[string]' is not assignable to type '(...args: any) => any'.

437     } ? ReturnType<T[key]['get']> : ReturnType<T[key]>;
                                                   ~~~~~~

typescript version: ^3.9.2

tsconfig.json:

{
  "compilerOptions": {
    "declaration": true,
    "esModuleInterop": true,
    "lib": [
      "esnext", "dom"
    ],
    "module": "commonjs",
    "moduleResolution": "node",
    "noEmitOnError": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "downlevelIteration": true,
    "outDir": "./dist",
    "types": [
      "node", "jest"
    ],
    "target": "es5",
    "typeRoots": [
      "./types",
      "./node_modules/@types"
    ]
  },
  "include": [
    "src/**/*"
  ]
}

@pikax
Copy link
Member

pikax commented May 25, 2020

Currently vue-next is not compatible with typescript 3.9

There's a PR open #1106

@yyx990803
Copy link
Member

Should be fixed after #1106. Thanks for the PR though!

@yyx990803 yyx990803 closed this Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need test The PR has missing test cases.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants