Bruce Pascoe

Results 421 comments of Bruce Pascoe

@Andarist You're like the walking embodiment of "move fast and break things" 🚎

> I don't think this is likely to cause type-safety issues. Yeah, it's purely a display issue. It's legal to pass `undefined` for an optional parameter either way: ```ts declare...

It looks like inference, at least, is consistent in that case: [Playground link](https://www.typescriptlang.org/play/?ts=5.5.0-beta#code/C4TwDgpgBA8mwEsD2A7AhgGwKroE4gB5gA+KAXigAo1cBzAfgC4pgBKc0gNyQQBMAofqEhQAogA9IAY2ARe5KjQbMUAVwC2AIwi52ZLjwEB6I1DMA9ekPDQAYmgQYFcRKkw4ahNVp3F+JsyhLQWFoCWlZXgBBOgVwiBk5KAhxWRReAGdFOiYoBBQAMx0WPQM+KHoWKBUITh1-UwsrUKh7RxjaBTanFLTM7OU8wuK2DihucsrgaqgUWvqApv4gA) ```ts type ExpectedArg = Expected extends (arg?: infer t) => void ? t : never // ^?...

I believe the type system treats `(p?: number) => void` equivalently to `(p?: number | undefined) => void` in all cases - even if you write out the latter explicitly.

Yeah, optional params are weird, even in JS: ```js function foo(x = 42) { console.log(x); } foo(undefined); ``` You might expect that to print `undefined`, but it actually prints `42`!...

@rubenpieters > In more traditional programming language theory, the knowledge added is very similar to adding a lower bound `"t"

> When we see str === "t", we don't know that T is lower-bounded by "t" Don’t you, though? I mean, yes, you can *manually* instantiate the generic using an...

> It makes TSX more generic for use by any library, and less React specific But... you specifically asked for `react-jsx`...

> What's the difference between `seven` and `three` here? `four`. :trollface:

Related: https://github.com/microsoft/TypeScript/issues/56363 I think this comes down to the known limitation wherein `never`-returning functions can only affect control flow for a naked function call (which is the root cause of...