Skip to content

Type parameter should not be assumed truthy #27050

Closed
@ghost

Description

TypeScript Version: 3.1.0-dev.20180912

Code

function f<T extends string | undefined>(x: T): number {
    return x && 42;
}
f(undefined).toFixed();

Expected behavior:

Error -- the output may be "" or undefined.

Actual behavior:

No error. (Error at runtime.)

Metadata

Metadata

Assignees

Labels

DuplicateAn existing issue was already created

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions