Encountering an issue with Visual Studio 2015 update 3 where the error message states:
Uncaught ReferenceError: require is not defined
Specifically on:
import { Category } from "./Enums"; at runtime.
https://i.sstatic.net/aY2gZ.jpg
The reason behind this error is not entirely clear to me, especially since I am new to Typescript.
This is what enums.ts contains:
export enum Category { Biography, Poetry, Fiction, History, Children }
And interface.ts includes:
import { Category } from './enums';
export interface Book {
id: number;
title: string;
author: string;
available: boolean;
category: Category;
pages?: number;
markDamaged?: DamageLogger;
}
Within app.ts, the code involves importing from various files:
import { Category } from './enums';
import { Book, DamageLogger, Author, Librarian } from './interfaces';
import { UniversityLibrarian } from './classes';
function GetAllBooks(): Book[] {
let books = [
{ id: 1, title: 'Ulysses', author: 'James Joyce', available: true, category: Category.Fiction },
{ id: 2, title: 'A Farewell to Arms', author: 'Ernest Hemingway', available: false, category: Category.Fiction },
{ id: 3, title: 'I Know Why the Caged Bird Sings', author: 'Maya Angelou', available: true, category: Category.Poetry },
{ id: 4, title: 'Moby Dick', author: 'Herman Melville', available: true, category: Category.Fiction }
];
return books
Apart from that;