ethereum-abi-types-generator icon indicating copy to clipboard operation
ethereum-abi-types-generator copied to clipboard

Type-only imports

Open jackmellis opened this issue 3 years ago • 2 comments

Hi, we've been using this library to generate our abi type defs and it's pretty great. There are just a couple issues we often come across (and have to fix by hand in every generated file right now).

We're enforcing type-only import syntax (i.e. setting "importsNotUsedAsValues": "error" in our tsconfig) but the generated files just use regular imports which means we get tonnes of errors for the generated files.

error TS1371: This import is never used as a value and must use 'import type' because 'importsNotUsedAsValues' is set to 'error'.

  1 import {
    ~~~~~~~~
  2   ContractTransaction,
    ~~~~~~~~~~~~~~~~~~~~~~
...
  6   BigNumberish,
    ~~~~~~~~~~~~~~~
  7 } from 'ethers';
    ~~~~~~~~~~~~~~~~

Would it be easy enough to just change all imports to import type?

jackmellis avatar May 23 '22 12:05 jackmellis

Hey thanks for rasing the issue so your saying you want the import to be like:

  import type {
    ContractTransaction,
    BigNumberish,
  } from 'ethers';

joshstevens19 avatar May 23 '22 12:05 joshstevens19

Yep 👍

jackmellis avatar May 23 '22 13:05 jackmellis