dethcrypto / dethcrypto/TypeChain

Types cannot be imported when packaged

Open
#758 4 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.8k
Forks
376
PR merge metrics
No merged PRs in 30d

Description

### Discussed in https://github.com/dethcrypto/TypeChain/discussions/755

Originally posted by **rtman** August 25, 2022
We're trying to make our typechain types reuseable by packaging them up as a private npm package. However this seems to cause issues like the following when in use in nextjs.

```
./node_modules/@scopeName/packageName/index.ts
Module parse failed: Unexpected token (6:12)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| /* eslint-disable */
> import type * as openzeppelin from "./@openzeppelin";
| import type * as uniswap from "./@uniswap";
| import type * as contracts from "./contracts";
```

Here's the package.json for the package:

```
{"name": "@scopeName/packageName", "version": "1.0.0-88d8202", "main": "index.ts"}
```
The root of the package is the output dir of typechain, containing all the types as well as the copied artifacts dir from hardhat.

![Screen Shot 2022-08-25 at 10 28 35 AM](https://user-images.githubusercontent.com/20849135/186730937-d85eea8d-1d3c-4351-9d29-c8258f4cb8aa.png)

I've seen a few related issues to this but no resolution yet https://github.com/dethcrypto/TypeChain/issues/609#issue-1113620678 https://github.com/dethcrypto/TypeChain/issues/278#issuecomment-743359593 , would be great to get some guidance here or a fix.

We're using `"@typechain/ethers-v5": "^10.0.0",`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.