You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Was error, now okay. Should it be an error with `noImplicitReturns`?letq1=(): undefined{};// Was error, now okay. Should it be an error with `noImplicitReturns`?letq2=(): string|undefined{};// Differences with contextual typing?// Still an error, inconsistent with the above.letq3=()// No contextual type, will continue to error.letq4=()=>{};// inferred as () => void;letq5: ()=>undefined=q4;// Was error (with or without noImplicitReturns), now okay.// Should it still be an errorletq6=(): unknown=>{};// Was 'Not all code paths return a value' with noImplicitReturns.// Now it isn't.letq7=(b: boolean): unknown=>{if(b)return42;}
Took a PR to say "if the return type includes undefined, we allow implicit returns".
Thought these were caught by noImplicitReturns
Returning undefined implicitly
3 states
I can never return undefined - actually can.
I always return undefined - implict return is probably okay (at least in some mode?)
I sometimes return undefined
(void?)
Does noImplicitReturns really mean "no implicit returns every unless any and void"
Or bare undefined?
Fine. Who the heck does that unless they know what they're doing?
What about number | undefined?
any and unknown always swallow up other types.
What about number | void?
Usually people mean unknown?
Maybe number | undefined?
Contextual types?
Same issues as empty arrays though. Concerns with capture and constraints affecting the inferences.
Are there assumptions that we make about the getter based on the setter and vice-versa
I didn’t see this mentioned in the notes and I’m not even sure it’s relevant here but: set prop(value) {} -> type of value is inferred from getter return value.
External Tools Operating Over Multiple Projects
evanw/esbuild#3019
tsconfig.json
target
etc.?Implicit Returns with Explicit Return Type Annotations
#53559
undefined
, we allow implicit returns".noImplicitReturns
undefined
implicitlyundefined
- actually can.undefined
- implict return is probably okay (at least in some mode?)undefined
void
?)noImplicitReturns
really mean "no implicit returns every unlessany
andvoid
"undefined
?number | undefined
?any
andunknown
always swallow up other types.number | void
?unknown
?number | undefined
?undefined
?undefined
.unknown
?Divergent Getters and Setters
#53417
foo.bar = foo.bar
should always be allowed.document.body.style = document.body.style
makes this not true.T[keyof T]
?.d.ts
files?"set
parameter make something contravariant?The text was updated successfully, but these errors were encountered: