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
typeClick='click';functionisClick(event: string): event is Click{returnevent==='click';}functionvalidateClickEvent(event: string): Click{if(isClick(event)){returnevent;// this line raises a compilation error: Type 'string' is not assignable to type '"click"'}thrownewError('not click');}typeCreature={};typeAnimal={}&Creature;functionisAnimal(creature: Creature): creature is Animal{returntrue;}functionvalidateAnimalCreature(creature: Creature): Animal{if(isAnimal(creature)){returncreature;// this line does not raise any compilation error}thrownewError('not animal');}
Expected behavior:
Can apply type guard to string literal types.
Actual behavior:
Cannot apply type guard to string literal types.
The text was updated successfully, but these errors were encountered:
TypeScript Version:
1.8.2
Code
Expected behavior:
Can apply type guard to string literal types.
Actual behavior:
Cannot apply type guard to string literal types.
The text was updated successfully, but these errors were encountered: