Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing 'type' in some imports, causing issues with Sveltekit compiler configuration #732

Open
tfalencar opened this issue Jun 24, 2022 · 1 comment

Comments

@tfalencar
Copy link

tfalencar commented Jun 24, 2022

When trying to use the generated code for contract factories, in combination with SvelteKit, the following error appears:

'Overrides' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled. ts(1444).

On the following line (of a Dummy__factory.ts file):

import { Signer, utils, Contract, ContractFactory, Overrides } from "ethers";

Which can be solved by adding "type" to "Overrides":

import { Signer, utils, Contract, ContractFactory, type Overrides } from "ethers";

The default configuration in SvelteKit indeed activates both isolatedModules and preserveValueImports in its tsconfig.json "compilerOptions", see: https://kit.svelte.dev/docs/types#generated-types-default-tsconfig-json

If there is no impact/downsides to using type-only import, implementing the suggestion above would make the experience better for Svelte-kit projects.

@tfalencar
Copy link
Author

tfalencar commented Jun 24, 2022

Just found a similar issue : #636

I'm on typechain 8.1.0 and @typechain/ethers-v5 10.1.0, and since I see other imports using "import type", maybe something changed in ethers library, where "Overrides" became a type? I'm currently on ethers version 5.6.8.

Update: It appears that only "Factory" generated files suffer from the issue, so it makes me think something could've been accidentally left out / forgotten in #636 refactoring.

I inspected some other files and also "BigNumberish" is sometimes included without the "type" specification. Otherwise the other generated files look fine.

@tfalencar tfalencar changed the title Support for TypeChain with Sveltekit Support for TypeChain with Sveltekit, ethers 5.6.8 Jun 24, 2022
@tfalencar tfalencar changed the title Support for TypeChain with Sveltekit, ethers 5.6.8 Missing 'type' in some imports, causing issues with Sveltekit compiler configuration Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant