https://github.com/zemse/types-import-problem
Reproduction of error while importing types
https://github.com/zemse/types-import-problem
Last synced: about 1 year ago
JSON representation
Reproduction of error while importing types
- Host: GitHub
- URL: https://github.com/zemse/types-import-problem
- Owner: zemse
- Created: 2020-09-11T20:45:15.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-12T13:19:44.000Z (almost 6 years ago)
- Last Synced: 2025-02-09T02:29:33.755Z (over 1 year ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Discussion: [ethereum-ts/TypeChain#278](https://github.com/ethereum-ts/TypeChain/issues/278)
### File Structure
```js
├── dependencies
│ ├── type.d.ts // exports an interface
│ ├── const.ts // exports a simple number
│ └── index.ts // exports all from type and const
└── main.ts // imports the interface and the number but from dependencies/index.ts
```
This is a reproduction of a problem, when `dependencies/index.ts` that exports both a type defination file (`dependencies/type.d.ts`) and a typescript file (`const.ts`), is imported in `main.ts`.
Typescript compiler generates `main.js`, `dependencies/const.js` and `dependencies/index.js` that exports (`./const` and `./type`). But since `dependencies/type` is not resolved by node js, we get following error when doing `node main.js`:
```sh
$ node main.js
internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module './type'
Require stack:
- /types-import-problem/dependencies/index.js
- /types-import-problem/main.js
```
_Note: Actual path is replaced by ``_