mockit
  • mockit
  • Installation
  • Setup
  • Fixture
  • APIs
  • CLI
  • Advance
    • Typescript
    • Creating a custom server
    • Integrating with other tools
    • Using with webpack-dev-server
    • mockit.json
Powered by GitBook
On this page
  1. Advance

Typescript

npm install --save-dev @babel/core @babel/node @babel/register @babel/preset-typescript

Add @babel/preset-typescript to your .babelrc file.

{
    "presets": [
        [
            "@babel/preset-typescript",
            {
                "allExtensions": true,
                "isTSX": true
            }
        ]
    ]
}

After you have this, run the command

npx mockit start --compiler @babel/register

If you received complaints about SyntaxError: Unexpected identifier, then try to add @babel/preset-env to your presets list after installing it.

npm install --save-dev @babel/preset-env

{
    "presets": [
        "@babel/preset-env",
        [
            "@babel/preset-typescript",
            {
                "allExtensions": true,
                "isTSX": true
            }
        ]
    ]
}
PreviousAdvanceNextCreating a custom server

Last updated 5 years ago