Definitelytyped: @Types/Jasmine 'Matchers' must have identical type parameters.

Created on 28 Mar 2017  路  4Comments  路  Source: DefinitelyTyped/DefinitelyTyped

  • [ x ] I tried using the @types/jasmine package and had problems.

    • Authors: @borisyankov @theodorejb @davidparsson

When trying to use Jasmine types definition in awesome-typescript-loader for webpack i'm getting the following error

[at-loader] ./node_modules/@types/jasmine/index.d.ts:314:15
TS2428: All declarations of 'Matchers' must have identical type parameters.

Most helpful comment

@manindersoprasteria You need to update your

declare namespace jasmine {
  interface Matchers {
  ...

to

declare namespace jasmine {
  interface Matchers<T> {
  ...

All 4 comments

FIXED:

So angular documentation tells you to use a helper method for testing:
declare namespace jasmine {
interface Matchers {
toHaveText(actual: any, expectationFailOutput?: any): jasmine.CustomMatcher;
}
}

Since Matchers now strongly types it needed to be changed to

Hi Jordan ,
Above soln did not work for me.Could u please elaborate what i need to change in Matchers Interface?

@manindersoprasteria You need to update your

declare namespace jasmine {
  interface Matchers {
  ...

to

declare namespace jasmine {
  interface Matchers<T> {
  ...

@manindersoprasteria you'll also need @types/jasmine version that has that change for the Matchers interface (e.g. =< 2.6)

Was this page helpful?
0 / 5 - 0 ratings