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
{{ message }}
Repository navigation
Suggestion: Let null assertion (!) operator block "used before assigned" errors #11463
a.ts(5,1): error TS2454: Variable 'n' is used before being assigned.
The problem is fixed by using let n: number | undefined, but it's not obvious that that's the solution, and it would be intuitive for the ! operator to work in this situation.
Aside: I don't see the ! operator documented in the handbook.
Yes, some solution to immediately invoked callbacks would be great. Mark Wubben (@novemberborn) and others have had issues trying to convert a Promise into a deferral and we have had to actually assign noop functions to values to work around the CFA. For example:
Activity
kitsonk commentedon Oct 9, 2016
Yes, some solution to immediately invoked callbacks would be great. Mark Wubben (@novemberborn) and others have had issues trying to convert a
Promiseinto a deferral and we have had to actually assign noop functions to values to work around the CFA. For example:Which sort of seems silly. I assume we would rewrite it as this with this proposal:
I also second the "undocumented" nature of
!. Several of the team found it by accident by searching issues.kitsonk commentedon Oct 11, 2016
As I mentioned in #11498 I am more supportive of an annotation that indicates that the function is immediately invoked than this solution.
RyanCavanaugh commentedon Oct 31, 2016
Approved since "not assigned yet" is really the same thing as "still has
undefinedin its domain"fix microsoft#11463, null assertion block uninitialized error
fix #11463, null assertion block uninitialized error (#14020)