O'Reilly logo

TypeScript Blueprints by Ivo Gabe de Wolff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Migrating each file

When the build system is set up, you can start with migrating files. It is easiest to start with files that do not depend on other files, as these do not depend on types of other files. To migrate a file, you must rename the file extension to .ts, convert the module format to ES modules, correct types that are inferred incorrectly, and add types to untyped entities. In the next sections, we will take a look at these tasks.

Converting to ES modules

In TypeScript files you cannot use CommonJS or AMD directly. Instead you must use ES modules, like we did in the previous chapters. For an import, you must choose from these:

  • import * as name from "package", imports the whole package, similar to var name = require("package") in CommonJS. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required