utility.ts
let books = [
{ id: 1, title: \"the dark window\", author: \"krishna\", available: true },
{ id: 2, title: \"naked eye\", author: \"sydney
I think the title is incorrect and what you really trying to do is running TypeScript applications in te browser which is totally different yo "Run TypeScript in the browser, right?
In that case to get started with TypeScript I recommend you to not use require.js add instead a bundler-like tool like a tool like parcel, webpack, browserify, rollup. parcel is super easy : For your example, 1) remove ALL script tags and add only the following: then "compile" that html with parcel theFile.html or build for production : parcel build theFile.html
if I was right, could you please change the title of this question since is confusing and misleading ? thanks.
Now, on the other side, If you really want to run TypeScript as the title say, typescript is fully compatible with the browser (the .js file library is node_modules/typescript/lib/typescript.js ). just import it as another module or load the file in a script tag and use the Compiler API..
This project contains my research on the topic with several working examples and demo apps and some tools: https://github.com/cancerberoSgx/typescript-in-the-browser