09:49
<annevk>
Anyone here familiar with the TypeScript community? Is https://github.com/heycam/webidl/issues/60#issuecomment-676033407 intentional?
09:54
<jgraham>
https://stackoverflow.com/questions/58885485/why-does-typescript-have-both-void-and-undefined
09:56
<jgraham>
(top answer seems to be from someone who works in TS)
09:58
<annevk>
That's useful, but I don't think it helps explain the example
09:59
<annevk>
It explains why void has usage in TypeScript (which is pretty different from what IDL used it for, afaict)
10:05
<jgraham>
I expect the reason is that once you are treating undefined as a type, and you have a rule that functions which return void can't return a value of any specific type, allowing them to actually contain "return undefined" because that's what js does is actually more work
10:06
<jgraham>
and is at least arguably wrong, since the return value isn't accessible in well typed code
10:17
<annevk>
jgraham: the case under discussion is that the return type is undefined and there's an error because there's no return statement
10:17
<annevk>
jgraham: a function whose return type is void is allowed to return undefined in TypeScript
10:22
<jgraham>
Oh yeah, sorry I misread the example
10:24
<jgraham>
I'm mildly surprised that the case with void and an explicit return works, but pretty unsurprised that the case with undefined and no return doesn't work
10:28
<annevk>
jgraham: it's weird though as void with return 3 does not work, only return undefined works
10:36
<jgraham>
Maybe `return undefined` is internally the same as bare `return` and the latter is needed for early return in void functions
10:40
<cybai>
looks like using `undefined` as return type will force developers to write `return undefined` explicitly
10:40
<cybai>
https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABFApgZygCgJQC5HgAmKwMYKhiA3gFCKIQJpwA2KAdC3AOaYBEACxQBPPtgDcdRACcUUENKRESZCpIC+NIA
10:41
<annevk>
cybai: yeah, the question is if that's intentional, and if it is, why?
10:42
<cybai>
annevk: oh, I see the question
10:50
<jgraham>
Note that bare `return` also works in that case
10:51
<jgraham>
Again suggesting that `return` and `return undefined` are treated as equivalent.
11:48
<cybai>
I just found this issue (https://github.com/microsoft/TypeScript/issues/36288) to suggest allowing `undefined` as return type in non-returning functions but there's no clue if the current behavior is intentional or not in the issue
20:13
<Domenic>
annevk: when you have time it might be good to review/merge the imperative shadow DOM API PRs on DOM and HTML.
21:22
<Domenic>
annevk: JakeA: and any others who love the navigation algorithm: thoughts and bikesheds on https://github.com/whatwg/html/issues/5847 welcome.