Closed
Description
Reported by @wycats. Compile this under strictNullChecks
and noImplicitAny
.
declare function someAbstraction(x: any): any;
let x: string;
someAbstraction(() => {
x = "hello";
});
// All of the following are errors.
x;
x as any;
x!;
I'd argue that both type assertions should be able to signal to the type system that the variable has been initialized.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
RyanCavanaugh commentedon Dec 12, 2016
Duplicate #11463
mhegazy commentedon Dec 13, 2016
declaring
x
asstring | undefined
should make these all work though.