Skip to content

Typechain fails where there are no contracts in a shared parent directory #772

@alexdupre

Description

@alexdupre

Here is a sample artifacts hierarchy structure to reproduce the bug:

contracts/1/interfaces/IOne.sol/IOne.json
contracts/2/interfaces/ITwo.sol/ITwo.json

Running typechain on a single directory works fine, typechain --target ethers-v5 --out-dir './typechain' './contracts/1/**/*.json' generates the following files:

./typechain/common.ts
./typechain/factories/index.ts
./typechain/factories/IOne__factory.ts
./typechain/index.ts
./typechain/IOne.ts

On the other hand, trying to generate the types for both contracts concurrently with typechain --target ethers-v5 --out-dir './typechain' './contracts/**/*.json' generates the following error:

Error occured:  'from' expected. (4:24)
  2 | /* tslint:disable */
  3 | /* eslint-disable */
> 4 | import type * as  from './..';
    |                        ^
  5 | export type {  };
  6 | export * as 1 from './1';
  7 | export * as 2 from './2';

and some files are generated outside the requested out-dir:

./1/interfaces/IOne.ts
./2/interfaces/ITwo.ts
./typechain/common.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions