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

Typescript mismatch with toBeTrue/toBeFalse as of @types/jasmine 3.5.0 #124

Closed
tomyam1 opened this issue Nov 28, 2019 · 6 comments
Closed

Comments

@tomyam1
Copy link

tomyam1 commented Nov 28, 2019

Description

When using recent jasmine-expect 4.0.3 with @types/jasmine 3.5.0 we get the following errors:

TypeScript error: node_modules/jasmine-expect/dist/toBeFalse.d.ts(5,13): Error TS2717: Subsequent property declarations must have the same type.  Property 'toBeFalse' must be of type '() => boolean', but here has type 'ToBeFalse'.
TypeScript error: node_modules/jasmine-expect/dist/toBeTrue.d.ts(5,13): Error TS2717: Subsequent property declarations must have the same type.  Property 'toBeTrue' must be of type '() => boolean', but here has type 'ToBeTrue'.

Suggested Solution

This seems to be due this commit DefinitelyTyped/DefinitelyTyped@c0e76f8

Using @types/jasmine 3.4.6 for now

Help Needed

Not sure who got it right: jasmine-expect or @types/jasmine

@tomyam1 tomyam1 changed the title Typescript mismatch with toBeTrue/toBeFalse as of 3.5.0 Typescript mismatch with toBeTrue/toBeFalse as of @types/jasmine 3.5.0 Nov 28, 2019
@komyg
Copy link

komyg commented Dec 10, 2019

Hi,

I ran into the same problem with Jasmine in an Angular project. I managed to solve it by removing the jasmine-expect entry that I had in my tsconfig.spec.json file:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
    "types": [
      "jasmine",
      "node",
      "jasmine-expect" # Removed this Line.
    ]
  },
  "files": [
    "test.ts",
    "polyfills.ts"
  ],
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ]
}

@Necroskillz
Copy link

jasmine 3.5 now has it's own toBeTrue and toBeFalse matchers, so they could just be removed from this library.

@RobARichardson
Copy link

Had to revert back to Jasmine Core 3.4.0 to get around this issue for now.

@devoto13
Copy link

devoto13 commented Mar 18, 2020

@JamieMason Would you be willing to accept a PR to remove expectationFailOutput?: any parameter from .toBeTrue() and .toBeFalse() matchers to prevent conflict with built-in matchers with the same name available as of Jasmine 3.5.0? This will require a major release as it is a breaking change.

Not suggesting complete removal of the matchers as Jest does not have them and also because it will affect more people then removal of the optional parameter.

For Jasmine expectationFailOutput works because of an implementation detail and is not a supported usage. That's why Jasmine 3.3.0 introduced .withContext() as supported way to add more information to the assertion.

Not sure how does this influence Jest users of the library though.

PS I will also try to deprecated expectationFailOutput parameters in @types/jasmine package in the coming weeks. If that goes through it should be a good idea to deprecate this parameter in all jasmine-expect matchers, so people would migrate from the unsupported usage.

@ShaneYu
Copy link

ShaneYu commented Jul 31, 2020

Is there any progress on this @JamieMason? The read me details that this library supports all versions of jest and Jasmine; but currently doesn't work with the last few releases of Jasmine.

A huge library of test matchers for a range of common use-cases, compatible with all versions of Jasmine and Jest.

@hoeni
Copy link

hoeni commented Aug 31, 2020

Did anyone here find a better workaround than pinning down Jasmine and its types to 3.4 until this gets fixed for good?

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

No branches or pull requests

8 participants