1.3.4 • Published 6 years ago

adonisjs-types v1.3.4

Weekly downloads
9
License
MIT
Repository
-
Last release
6 years ago

Installation

  1. Install adonisjs-types package:

    npm i --save-dev adonisjs-types

  2. Add following tsconfig.json file in your project root:

    {
      "compilerOptions": {
        "allowJs": true,
        "moduleResolution": "node",
        "lib": [
          "es2015"
        ]
      },
      "files": [
        "node_modules/adonisjs-types/index.d.ts"
      ],
      "include": [
        "./**/*.js"
      ],
      "exclude": [
        "node_modules"
      ]
    }

This is a minimal required configuration for types to work. You can tweak it further.

Usage

Types are provided through use method, for example: const Env = use('Env') will be correctly typed. If you want to get intellisense on controller methods, jsDoc will help:

class WelcomeController {
  /**
   * @param {Adonis.Http.Context} ctx
   */
  hello(ctx) {
    //
  }
}

// Or, if you want destructuring:

class WelcomeController {
  hello(/** @type Adonis.Http.Context */ { request, response }) {
    //
  }
}
1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago