adonisjs-types
TypeScript icon, indicating that this package has built-in type declarations

1.3.4 • Public • Published

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 }) {
    //
  }
}

Readme

Keywords

Package Sidebar

Install

npm i adonisjs-types

Weekly Downloads

4

Version

1.3.4

License

MIT

Unpacked Size

14.8 kB

Total Files

4

Last publish

Collaborators

  • thisdotvoid