Typescript. Namespaces

namespaces allow logically group our code

namespace Animals {

    interface Animal {
        sayHi(): void
    }

    class Dog implements Animal {
        sayHi(): void {
            console.log('av-av');
        }

    }

    const isDog = (object: any): boolean => {
        return 'sayHi' in object;
    }

    const countDogs = 3;


    let dog = new Dog();
    console.log('isDog', isDog(dog));
}


This entry was posted in Без рубрики. Bookmark the permalink.