Skip to content

strictNullChecks thinks ambient declarations are unassigned and complains when they're used #7626

Description

@Arnavion

TypeScript Version:

3853bb8 (master after merging #7140 )

Code

declare const foo: string;
console.log(foo);

tsc -t es5 --strictNullChecks ./foo.ts

Expected behavior:

Compiles.

Actual behavior:

foo.ts(2,13): error TS2454: Variable 'foo' is used before being assigned.


Allowing foo to be undefined makes it compile, but this shouldn't be required of course.

declare const foo: string | undefined;
console.log(foo);

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions