Suggestion: Replace `any` with generic types to be able to match the actual and expected values
See original GitHub issueHey 👋
Thank you for the great library, I have one specific suggestion here regarding TypeScript
When I use assert.equal
, I expect the types of actual
and expects
values to be the same or expects
to be narrowed from actual
The explanation in Playground – https://tsplay.dev/NnXBxW
Do you think it makes sense and I can start working on that? I really want that change as I used it in jest
but didn’t really like the experience (I needed to specify it myself to make it implicit)
WDYT?
Other solutions:
earljs
– https://tsplay.dev/Wk5aLN- TODO: add more examples
I see any
for a lot of methods:
I want to cover it for at least:
-
is
-
equal
-
type
-
instance
-
snapshot
(to be able to work with string literal types) -
fixture
(same as forsnapshot
)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Generic Types - Learning the Java Language
A generic type is a generic class or interface that is parameterized over types. The following Box class will be modified to demonstrate...
Read more >Use generics to enforce same type properties in an array of an ...
I'm looking to use generics to enforce that the type of val1 should match the type of val2 for each element in an...
Read more >Typescript forbids safety checks that check equality of values ...
When a function is passed two arguments of two different generic types, ... The real type of equality is <T>(x: T, y: T)...
Read more >4.1. Generic Types - Java in a Nutshell, 5th Edition [Book]
In order to use a generic type like this, you specify actual types for the type variable (or variables), producing a parameterized type...
Read more >Java Generics Example Tutorial - Generic Method, Class ...
We use <T> to create a generic class, interface, and method. The T is replaced with the actual type when we use it....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It will be very cool to have the same typing on both side of
is(a, b)
andequal(a, b)
Thanks for the progress @Beraliv ~! Turns out, this was all that was needed (similar idea as yours!):