Skip to content

Change default Context type to unknown #2186

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

Merged
merged 1 commit into from
Jul 15, 2019
Merged

Conversation

novemberborn
Copy link
Member

Previously, the Context was typed as an empty object. This suddenly started giving problems when typing t.try() (#1947 (comment)). Setting it to unknown seems reasonable.

This may break some code, but I'm not sure how you'd use context without typing it, and IIRC there was a non-major TypeScript change that led to similar breakage regarding the {} type. It seems like the kind of breakage that TypeScript users are used to, so we shouldn't need a major bump to release this. @sindresorhus?

Copy link
Member

@sindresorhus sindresorhus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default now in TS too: https://devblogs.microsoft.com/typescript/announcing-typescript-3-5/

Generic type parameters are implicitly constrained to unknown

@novemberborn novemberborn merged commit 2fc7d56 into master Jul 15, 2019
@novemberborn novemberborn deleted the unknown-context branch July 15, 2019 19:33
@vintprox
Copy link

Used along with TypeScript, context of unknown type triggers errors when I try to add property to it. Shouldn't it be of any type?

@novemberborn
Copy link
Member Author

You can type context with some type casts, see https://github.com/avajs/ava/blob/master/docs/recipes/typescript.md#typing-tcontext. I'm working on a new way of building test() functions where the context can be inferred, keep an eye on #2435 for that.

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

Successfully merging this pull request may close these issues.

3 participants