-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
expectError strict behaviour #40
Comments
What would be the reason for wanting IMO, if it were to behave in that way, it would be a little confusing, as there would be no TypeScript error effected when assigning to a wider type, so there is no error to expect. If it's desirable for it to behave like that, I think it needs a new name that better describes what it does. Something like BTW, the expectations for testing deprecations - that I mentioned in that RxJS issue - would need a similar pair of functions: |
Perhaps these situations would be simpler if the package include a general negation mechanism for expectations? |
Have you given any further consideration to this? IMO, an expectation named |
Further to the above, with RxJS we use dtslint to test arguments that are passed to functions - presumably With arguments, I would expect an expectation failure to be effected only if the TypeScript compiler effects an error. I would not expect a failure to be effected when passing an argument that has a type that's narrower than the parameter type. And, given that, I would expect the return value to be treated in a similar manner: no expectation failure unless the TypeScript compiler effects an error. |
I need feedback on the behaviour of the
expectError
assertion.The
expectType
assertion is strict. Which means thatexpectType<string | number>(concat('a', 'b'))
will fail becausestring | number
is defined too wide. See the docs.I didn't change anything for
expectError
as I wasn't sure on the exact behaviour.@cartant asked if it would behave like this (see ReactiveX/rxjs#4871 (comment)).
The reason behind it could be that because the type is too wide, the assertion is an error and that's what you expect.
I also discussed this with @sindresorhus and he indicated that maybe we should hard fail on that assertion.
I definitely could use feedback on this topic here :).
// @BendingBender
The text was updated successfully, but these errors were encountered: