Advertisement ยท 728 ร— 90

Posts by Christopher Horobin

Precompilation is not the same as generation.

10 months ago 0 0 0 0

Precompiled types require check time and emit which is slower than inference. You just live with stale types for longer

10 months ago 0 0 1 0

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

10 months ago 1 0 0 0

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

10 months ago 1 0 1 0

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.

10 months ago 1 0 1 0

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

10 months ago 1 0 1 0

Now is the time to design for typescript and write plenty of types

10 months ago 1 0 0 0

Just think how many more types we can write now

10 months ago 1 0 1 0
Advertisement

tsgo is really incredible

10 months ago 1 0 1 0

Also feels less natural to me

10 months ago 1 0 0 0

Mapped types feel too verbose for this purpose

10 months ago 1 0 1 0

`extends any` is my favourite use of `any` to trigger conditional type distribution.

10 months ago 1 0 1 0

In the end. Its about 'rich types', adding precise types where it matters most

11 months ago 1 0 1 0

Or should it be the most suitable type? Or are we saying 'type-safe' stuff just cares about TypeScript. If so, that is sad.

11 months ago 1 0 0 0

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?

11 months ago 3 0 2 0

I just see them as if expressions

11 months ago 2 0 0 0

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

11 months ago 3 0 1 0

Maybe a unpopular opinion but type level code actually looks nice after you get used to it

11 months ago 4 0 2 0
Advertisement

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

1 year ago 1 0 0 0

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.

1 year ago 2 0 1 0

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.

1 year ago 1 0 0 0

I want to hope types will get more ambitious with a faster typescript. Not more sloppy. That would be sad

1 year ago 3 0 1 0

Completely gobsmacked. Never thought I would see the day this type checks in less than a second

1 year ago 4 0 0 0

I use mapped types when i want to transform an object or tuple

1 year ago 0 0 0 0

I prefer to use distributive conditionals to transform unions

1 year ago 0 0 0 0

I prefer to compose types bottom up with interfaces rather than top down with Omit or Pick

1 year ago 0 0 0 0
Advertisement

Mapped types are great. I just see them used in places where I would not all the time

1 year ago 1 0 3 0

Of course intuitions on this is good for library authors to build. Devs should just keep thinking in terms of structural typing imo

1 year ago 0 0 0 0

And you can go even further by adding variance annotations

1 year ago 1 0 1 0

So sometimes you can just replace an anonymous object literal type with a named type

1 year ago 1 0 1 0