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
There's several requests for people to be able to say "I want to be able to talk about a specific instantiation of a function or constructor". For example, if you wanted an alias of Map that could only work for strings to Errors.
Also when you write code like foo<T>(yadda), this is already valid code in JavaScript.
It's relatively meaningless, but there's already auto-generated code with a semantic difference.
In retrospect could have imagined separating out type argument instantiation with invocation.
Already have something like this in extends clauses - ExpressionWithTypeArguments.
So what if you could write:
constErrorMap=Map<string,Error>;newErrorMap();// or directly at the use-sitenew(Map<string,Error>)();// does not work today
Similarly
functionmakeBox<T>(x: T): Box<T>{// ...}constmakeAppleBox=makeBox<Apple>;makeAppleBox(newApple());// or directly at the use-site(makeBox<Apple>)(newApple());// does not work today
Idea: runs through existing signatures that take the appropriate number of type arguments, and drops any others.
Distributes across unions, and must apply to at least one signature in one type in the union. If no signatures got resolved, then it's an error.
Have to parenthesize? Means that this is at odds with optional chaining.
This is contentious - seems like if one motivation is avoiding conflict with JS, it's iffy.
typeof?
typeof Map<A, B> vs (typeof Map)<A, B> - slightly different!
Can you express this both of these?
No. Type references need to be qualified names.
Is it confusing to have both of these constructs?
Maybe not, but may want both.
A bit confusing that you can't control between call and construct signatures.
Conclusion:
Return to this.
Properties on unknown when --strictNullChecks false
Expressions with Type Arguments
There's several requests for people to be able to say "I want to be able to talk about a specific instantiation of a function or constructor". For example, if you wanted an alias of
Map
that could only work forstring
s toError
s.Also when you write code like
foo<T>(yadda)
, this is already valid code in JavaScript.In retrospect could have imagined separating out type argument instantiation with invocation.
Already have something like this in
extends
clauses - ExpressionWithTypeArguments.So what if you could write:
Similarly
Idea: runs through existing signatures that take the appropriate number of type arguments, and drops any others.
Distributes across unions, and must apply to at least one signature in one type in the union. If no signatures got resolved, then it's an error.
Have to parenthesize? Means that this is at odds with optional chaining.
typeof
?typeof Map<A, B>
vs(typeof Map)<A, B>
- slightly different!Conclusion:
Properties on
unknown
when--strictNullChecks false
#47494
message
off ofunknown
.strictNullChecks
but withuseUnknownInCatchVariables
unknown
, this all makes no sense."{}
used to be the top type, moved towardsunknown
.{}
outside ofstrictNullChecks
mode.unknown
always assignable to{}
outside ofstrictNullChecks
.The text was updated successfully, but these errors were encountered: