How to use typescript in browser?

后端 未结 4 548
無奈伤痛
無奈伤痛 2020-12-31 04:21

utility.ts

let books = [
    { id: 1, title: \"the dark window\", author: \"krishna\", available: true },
    { id: 2, title: \"naked eye\", author: \"sydney         


        
4条回答
  •  自闭症患者
    2020-12-31 05:16

    Browsers do not yet support javascript modules. Until they do you will need to include browserify into your development workflow. Browserify concatenates your modules into a browser friendly bundle.

    Browserify is very simple to get working in a typescript workflow. If you are feeling adventurous you can look at other bundlers like WebPack, Rollup or SystemJs.

    Note, this is not specific to TypeScript. When developing any modern javascript (es6 or CommonJS modukes) you will need to bundle modules for the browser.

提交回复
热议问题