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.
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. ...