katana.ts

The katana.ts file declares a base class named BaseWeapon and a derived class named Katana:

import { Weapon, Named } from "./interfaces"; 
 
export class BaseWeapon { 
    damage = 25; 
} 
 
export class Katana extends BaseWeapon implements Weapon, Named  { 
    name = "Katana"; 
    public tryHit(fromDistance: number) { 
        return fromDistance <= 2; 
    } 
} 

Get Learning TypeScript 2.x - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.