2 ms·
> that system doesn't even give you the benefit of being sound I have hated parts of the TS type system with passion but this is the first time I'm hearing abo
by codethief 3y ago
> that system doesn't even give you the benefit of being sound
I have hated parts of the TS type system with passion but this is the first time I'm hearing about unsoundness. Would you mind elaborating?
- ReleaseCandidat 3y agohttps://www.typescriptlang.org/docs/handbook/type-compatibility.html#a-note-on-soundness https://www.typescriptlang.org/docs/handbook/type-compatibil... For example: https://www.typescriptlang.org/docs/handbook/type-compatibility.html#function-parameter-bivariance https://www.typescriptlang.org/docs/handbook/type-compatibil... https://www.typescriptlang.org/docs/handbook/type-compatibility.html?#optional-parameters-and-rest-parameters https://www.typescriptlang.org/docs/handbook/type-compatibil... Or the type of an array and its elements: const arr : number[] = [1] but const this_is_actually_undefined : number = arr[456] so it should be const correct_type : number | undefined = arr[idx] And there are way more, I'm too lazy to search for them or think about them.
- codethief 3y agoAh, yes, I've stumbled about plenty of such cases – TIL that "unsoundness" is an established term for them. Thanks so much!