I'm working on a function that returns { setTimeout } when called in an environment where Jest does not exist, and { setTimeout: jest.fn() } when it does. declare namespace jest {} export type JestExists = typeof jest extends { fn: Function } ? true : false; 1/?
-
-
-
The function's return type is something like: JestExists ? Pick<Window, 'setTimeout'> : { setTimeout: jest.Mock }. Relies on *.test.* files being included in a separate tsconfig project than your source files Pretty cool IMO
2/2 - Još 1 odgovor
Novi razgovor -
-
-
working on a library to add side effects to "useReducer". That allows to write this code. All of it is typechecked thanks to conditional types.pic.twitter.com/dMcVyhy7Bl
- Još 4 druga odgovora
Novi razgovor -
-
-
Oh also, for a library that needs to replace everything on the Console object, this type removes the non-Function parts to leave a type with just the member functions: https://github.com/Codecademy/console-fail-test/blob/24e0841ba50176bf6e78419a6a757f063a112d80/src/types.ts#L11 …
Hvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
-
-
Matchkin (https://github.com/jviide/matchkin ) contorts conditional & inference types to implement statically checked exhaustive matching. Maybe it would've been possible to get something similar w/o those specific TS features. It has its uses, though. Sorry for the potato quality video
pic.twitter.com/OORQoiSxA0Hvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
-
-
Oh do I have some content for you - will message when I get home
Hvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
-
-
Well the best case I’ve seen is when an API I was using sent back an integer value as both a number and a string. It completely occurred randomly
Hvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
-
-
We had an api client that had methods for our backend services. We wanted to be able to load test new features on our production hosts without leaking the names of endpoints. Using conditional types helped us keep type safety without exposing a runtime artifact
Hvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.
Matthew not Matt.
Engineer
Organizer
Broadway Fan
Slytherin

he/him