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
Closed

t.like() feedback #2518

novemberborn opened this issue Jun 14, 2020 · 4 comments
Labels

Comments

@novemberborn
Copy link
Member

@novemberborn novemberborn commented Jun 14, 2020

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

@sindresorhus sindresorhus commented Jun 14, 2020

I like it

@novemberborn
Copy link
Member Author

@novemberborn novemberborn commented Jun 30, 2020

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

@sindresorhus sindresorhus commented Jun 30, 2020

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

novemberborn added a commit that referenced this issue Jul 4, 2020
@novemberborn
Copy link
Member Author

@novemberborn novemberborn commented Jul 4, 2020

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

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

novemberborn added a commit that referenced this issue Jul 4, 2020
@novemberborn novemberborn unpinned this issue Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants