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

t.like() feedback #2518

Closed
novemberborn opened this issue Jun 14, 2020 · 4 comments · Fixed by #2550
Closed

t.like() feedback #2518

novemberborn opened this issue Jun 14, 2020 · 4 comments · Fixed by #2550
Labels

Comments

@novemberborn
Copy link
Member

Have you tried our new t.like() assertion? What did you think of it? Did it behave the way you expected it to?

Let us know so we can make it not require opt-in.

(Also, we need some help making our ESLint plugin recognize it.)

@sindresorhus
Copy link
Member

I like it

@novemberborn
Copy link
Member Author

There is an issue with the selector type:

ava/index.d.ts

Line 133 in f72fab4

(value: any, selector: Record<string, unknown>, message?: string): void;

type Foo = {
  foo?: 'foo',
  bar?: 'bar'
}

const foo: Foo = {}
const { foo: _, ...expected } = foo

t.like(bar, expected)

This throws a type error because { bar?: 'bar' } cannot be assigned to Record<string, unknown>.

Not sure yet which type we should use. @sindresorhus?

@sindresorhus
Copy link
Member

I think you have to use Record<string, any>. It's a dumb TS thing.

@novemberborn
Copy link
Member Author

I think you have to use Record<string, any>.

Ah thanks. Fixed with #2532 and a handy regression test.

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

Successfully merging a pull request may close this issue.

2 participants