-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.0.2
Code
interface Pet {
name: string;
}
function isPet(pet: any): pet is Pet {
return typeof pet.name === "string";
}
export function speak<TPet extends Pet>(pet: TPet, voice: (pet: TPet) => string): string {
if (!isPet(pet)) {
throw new Error("Expected \"pet\" to be a Pet");
}
return voice(pet); // line 14
}Expected behavior:
Module compiles without error when --strictNullChecks is enabled OR disabled.
Actual behavior:
-
Module compiles without error when
--strictNullChecksis disabled. -
The following error is produced when
--strictNullChecksis enabledbug.ts(14,18): error TS2345: Argument of type 'Pet' is not assignable to parameter of type 'TPet'.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue