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
Problem today: When strictNullChecks is off, null and undefined are widened to any before generic inference occurs
Example: f<T>(a: () => T, b: () => T): T under f(() => null, () => 1)
Proposal: Widen them later
Problem today: Excess property checking doesn't occur on a return expression contextually typed by a concrete object type
Examples: Countless
By not widening, we retain freshness and can correctly detect excess properties
Never widening is not the right solution
You have to widen if you end up inferring a type for a binding, otherwise object literals stay "fresh" forever which is wrong outside of a transient context
e.g. const a = () => { x: 3, y: 4 }; const b: () => { x: number } = ashould be legal, but wouldn't be if we kept the freshness around
Named function expressions can call themselves, which is problematic for functions with recursive returns
Solution: Only defer widening when a contextual signature type is present
Found a bug in our own codebase
Found real problems in DefinitelyTyped (either bad docs or copy/paste errors)
Found things that appear to be bugs in RWC
Limitations: Same problems when contextual types aren't present (e.g. overload positions)
f<T>(a: () => T, b: () => T): T
underf(() => null, () => 1)
const a = () => { x: 3, y: 4 }; const b: () => { x: number } = a
should be legal, but wouldn't be if we kept the freshness aroundconst { x = () => true }/*: OptionalAnnotation */ = { x: () => false };
wideningTuples2.ts
testcase?override
without a flag to enforce it is mostly useless--strict
because no one has the ability to writeoverride
yetpublic abstract override foo()
public static override foo()
x[i]
forconst i
pedantic
thesaurus partypedantic
stringent
rigorous
(or if Ryan is listening,vigorous
🙃)conservative
indexedAccess
vsindexSignatures
--init-strict
or something--noFoo
flags already that aren't part of--strict
--noUncheckedIndexedAccess
--noUncheckedIndexedAccesses
--noUncheckedIndexes
--noUncheckedIndices
--noUncheckedIndexing
--noImplicitBounds
--noImplicitAccess
--noImplicitIndexAccess
--noUncheckedLookup
--checkArrayBounds
--noImplicitIndexing
--undefinedIndexSignatures
--noBoundsAssumptions
--skepticalIndexAccesses
--🤨
--letsRunAPoll
The text was updated successfully, but these errors were encountered: