WebApps 2

Migrate existing app to TypeScript

It is possible to migrate an old bundled JavaScript RESTApp/WebApp to start using TypeScript. It's possible to do in steps without having to rewrite all JavaScript code at once. You can have both TypeScript and JavaScript in your app during the transition period.

To get started all you need to do is follow these steps:

  1. Make sure Sitevision dependencies are up to date
    1. npm install @sitevision/sitevision-scripts
    2. npm install @sitevision/api
  2. Update the eslint config in package.json by adding
    @sitevision/eslint-config-typescript
  3. Add a tsconfig.json to the root of your app. You can use the one from sitevision-scripts found here.
    1. If your planning on a gradual transition to TypeScript add the allowJs-option.
  4. If you are using css-modules in your app (the Sitevision app does this by default) you'll have to add declaration for your (s)css-files. You can copy the one from sitevision-scripts found here.