question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[1.3.*] Types of parameters '__0' and 'value' are incompatible.

See original GitHub issue

Bug Report

- [x] bug report
- [ ] feature request

Versions.

@typescript: 2.4.2
@rxjs: 5.4.3
@angular/cli: 1.3.1
node: 8.0.0
os: linux x64
@angular/animations: 4.3.4
@angular/cdk: 2.0.0-beta.8
@angular/common: 4.3.4
@angular/compiler: 4.3.4
@angular/core: 4.3.4
@angular/flex-layout: 2.0.0-beta.8
@angular/forms: 4.3.4
@angular/http: 4.3.4
@angular/material: 2.0.0-beta.8
@angular/platform-browser: 4.3.4
@angular/platform-browser-dynamic: 4.3.4
@angular/router: 4.3.4
@angular/cli: 1.3.1
@angular/compiler-cli: 4.3.4

Repro steps.

    let s: string = 'abc',
        b: boolean = true,
        n: number = 10;

    Observable.forkJoin([Observable.of(s), Observable.of(b), Observable.of(n)])
        .map(([s, b, n]: [string, boolean, number]) => s);

The log given by the failure.

ERROR in file.ts (6,18): Argument of type '([s, b, n]: [string, boolean, number]) => string' is not assignable to parameter of type '(value: boolean[], index: number) => string'.
  Types of parameters '__0' and 'value' are incompatible.
    Type 'boolean[]' is not assignable to type '[string, boolean, number]'.
      Property '0' is missing in type 'boolean[]'.

Desired functionality.

This code gets compiled on v1.2.7 but fails on v1.3.*

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
karsercommented, Aug 23, 2017

Thanks @clydin. There are 3 working examples that get compiled under angular-cli 1.3.1 and TS 2.4:

  1. cast the array parameter as any[]
Observable.forkJoin([Observable.of(s), Observable.of(n)])
    .map(([s, n]: any[]) => s);
  1. surprisingly, I found out that if I pass observables into forkJoin not as an array but as a function arguments, the error disappears, so my original example works:
Observable.forkJoin(Observable.of(s), Observable.of(n))
    .map(([s, n]: [string, number]) => s);
  1. manually define the generic type parameter on forkJoin.
Observable.forkJoin<string,number>(Observable.of(s), Observable.of(n))
    .map(([s, n]) => s);
1reaction
karsercommented, Aug 21, 2017

@clydin Could you please provide some reference that forkJoin doesn't work with a multi-type array in TS 2.4? Is it by design? What would be a solution in this case? In this example forkJoin accepts observables of multiple types. I removed all the type casts from my previous code but I’m getting ERROR in file.ts (5,38): Argument of type 'string' is not assignable to parameter of type 'number'.:

let s: string = 'abc',
    n: number = 10;

Observable.forkJoin([Observable.of(s), Observable.of(n)])
    .map(responses => takesB(responses[1]));

function takesB(n: number) {
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

is "Types of parameters '__0' and 'value' are incompatible" a ...
This causes an error because your function is explicit about accepting a the tuple type [any] . An array type is not assignable...
Read more >
Documentation - Type Compatibility - TypeScript
Type compatibility in TypeScript is based on structural subtyping. ... Enum values from different enum types are considered incompatible. For example,.
Read more >
Chapter 4. Types, Values, and Variables - Oracle Help Center
A NaN value is used to represent the result of certain invalid operations such as dividing zero by zero. NaN constants of both...
Read more >
Semantics
Variables can be defined using either their type (like String ) or by using the keyword def (or var ) followed by a...
Read more >
Function has a parameter whose default value is incompatible ...
Function has a parameter whose default value is incompatible with its declared type: false positive for iterable type ... This seems to apply...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found