hi! i’ve bumped from `9.17.3` to `10.1.2` and hav...
# pact-js
d
hi! i’ve bumped from
9.17.3
to
10.1.2
and having
Copy code
TypeError: includeWipPactsSince
looks like it cant be
undefined
anymore line triggering error
Copy code
includeWipPactsSince: isCI ? new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString().split("T")[0] : undefined,
m
Can you please raise a bug? We'll get it updated to ignore it if undefined
d
looks like some other parts doesnt like `undefined`s as well
1
m
thanks. We can probably omit all properties that are undefined before validating, and get them in one sweep. Thanks for raising 🙏
👍 1
d
looks like there are more ( or i didnt migrated well yet 😞)
Copy code
The pact consumer core returned false at 'uponReceiving'. This
should only happen if the core methods were invoked out of order

This is almost certainly a bug in pact-js-core. It would be great if you could
open a bug report at: <https://github.com/pact-foundation/pact-js-core/issues>
so that we can fix it.
will check more
m
Thanks. Let me know if you can get to the bottom of it. This probably means an object is being reused that shouldn’t
t
This isn’t a bug
Although it should be in the release notes
It’s a feature of typescript - typescript is protecting you from passing an invalid value to
includeWipPactsSince
Sorry, let me clarify - the type error isn’t a bug. The other thing I don’t know about.
do:
Copy code
{
  ...(someTest ?  { optionalParam: value } : {}),
}
instead of
Copy code
{
 optionalParam: someTest ? value : undefined,
}
We tightened up the types in a few places, and this should have been in the release notes. Apologies.
From memory, I think the release notes should have said: • Typescript users: Matchers have types now, which will help avoid common matcher mistakes. We’re not expecting any errors with correct matcher use, but please raise an issue if the new types are causing problems. • Typescript users: Tightened the types in a number of places. This doesn’t affect the behaviour, but there may be cases where users need to update their invocations to match the types more closely.
I think we didn’t fix the enum problem where you can’t say
logLevel: 'INFO'
. I think that’s worth fixing - Matt, I can make a PR if you like
Actually, looking at the code maybe we did fix that. Also I found this, which I did for users who aren’t using typescript: https://github.com/pact-foundation/pact-js-core/commit/7521c6121ec0523795c97ec5c422c3b6d6024dd8 Thinking about it now that the above has been raised, I think there’s a good argument that
foo: someTest ? value : undefined
was/is idiomatic in javascript, but I think warning that “this might be a mistake” is still valuable.
Also, what version of TypeScript are you using? Are you using
exactOptionalPropertyTypes
? I think the breaking change might be in your TS settings and not in Pact - https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-4.html#exact-optional-property-types---exactoptionalpropertytypes
Additionally, this hasn’t changed in 10.x - it was the same exact type back in pact-node, which is what 9.x uses. I think something else has changed, probably your typescript options.
d
thank you for such big text/explanation 🙂 what could cause this then, as apart from bumping pact noting changed?
cant find any
exactOptionalPropertyTypes
Copy code
"typescript": "4.7.4"
so looks like by replacing all
undefined
with
{}
it became better ( which is kinda weird )