Search code examples
typescriptionic4tslintdestructuringcapacitor

expected object-destructuring: '{ Network }' to have a typedef


I have enabled this on tslint rule like so:

"rules": { "typedef": [true, "array-destructuring"] }

Here

const { Network } = Plugins;

It shows this warning:

expected object-destructuring: '{ Network }' to have a typedef (typedef)

How to modify this const { Network } = Plugins;?

Capacitor Network


Solution

  • If you add tslint rules make sure you understand them first.

    First of all, the one causing that error is not array-destructuring, but object-destructuring.

    And the error means you have to provide the type of Plugins object.

    So should be

    const { Network }: PluginRegistry = Plugins;