Precompilation is not the same as generation.
Precompilation is not the same as generation.
Precompiled types require check time and emit which is slower than inference. You just live with stale types for longer
Honestly its likely not a very documented topic. Also I am pretty certain TS does an awful lot of caching regardless of if you are making and using loads of utility types. Best thing is letting instantiation and type counts plus tracing guide you
Its also worth checking both instatiations and type count. They are both useful, when both go down its a win-win. But if one goes up and the other goes down, it can probably vary which is faster
But its not always the case though. Sometimes you want A and B to be instantiated lazily, when they are used. And you only want to do the work for A and not B only when A is used.
Its probably the caching. If you know both A and B are always used in the majority of cases then having a shared util type which does the work once can definitely help
Now is the time to design for typescript and write plenty of types
Just think how many more types we can write now
tsgo is really incredible
Also feels less natural to me
Mapped types feel too verbose for this purpose
`extends any` is my favourite use of `any` to trigger conditional type distribution.
In the end. Its about 'rich types', adding precise types where it matters most
Or should it be the most suitable type? Or are we saying 'type-safe' stuff just cares about TypeScript. If so, that is sad.
The term 'type-safe' is used rather a lot. Is `string` 'type-safe'? Depends. Maybe we should be referring to the most precise type for 'type-safety'? But do we?
I just see them as if expressions
Types are pure functions. There are no side effects possible, like ever. The language is also quite small. I personally find this combination makes it easy to reason
Maybe a unpopular opinion but type level code actually looks nice after you get used to it
I think the designer of those languages has a better understanding of what language to choose for a code base they know very well than maybe anybody on the outside
Realisation that my first language was delphi as a child because my father liked it. My first actual toy projects in college were in c#, spent years in that language. Now I have spent 9 years in typescript.
There are some footguns which I have learnt to avoid regarding performance. If the compiler is 10 times faster then definitely some quirks become way less noticable. I wonder if things like conflicting properties with intersections might still be noticable.
I want to hope types will get more ambitious with a faster typescript. Not more sloppy. That would be sad
Completely gobsmacked. Never thought I would see the day this type checks in less than a second
I use mapped types when i want to transform an object or tuple
I prefer to use distributive conditionals to transform unions
I prefer to compose types bottom up with interfaces rather than top down with Omit or Pick
Mapped types are great. I just see them used in places where I would not all the time
Of course intuitions on this is good for library authors to build. Devs should just keep thinking in terms of structural typing imo
And you can go even further by adding variance annotations
So sometimes you can just replace an anonymous object literal type with a named type