Linting Types

Use TypeScript to type lint your es6 JSDoc annotated code.

Setup

npm init @open-wc linting-types-js

This is an OPTIONAL recommendation. You will need to opt-in by running the generator or following the manual steps.

Manual

  • yarn add --dev typescript
  • Copy tsconfig.json to tsconfig.json
  • Add these scripts to your package.json
    "scripts": {
      "lint:types": "tsc",
    },
    

What you get

For general information about types please see developing/types.

  • Awesome intellisense for @open-wc tools/helpers
  • Ability to jump directly to the source of @open-wc code via F12 (in vs code)
  • Type safety (To read more about why type safety can help you, go to: developing/types).

Usage

Run:

  • npm run lint:types to check if you have type errors

Type linting error example

$ npm run lint:types

> foo-bar@ lint:types /path/to/foo-bar
> tsc

test/foo-bar.test.js:7:22 - error TS2554: Expected 1 arguments, but got 2.
7     const el = await fixture('<foo-bar></foo-bar>', { hasMoreOptions: false });
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error.
Last Updated: 9/10/2019, 9:52:43 AM