Investigate TSC compilation errors when using as package
Opened this issue · 5 comments
cgewecke commented
Investigate TSC compilation errors when using as package
rootulp commented
I'm encountering TSC errors when adding set.js as a dependency to index-ui however the error appears a bit misleading:
Failed to compile.
/Users/rootulp/git/index-ui/src/contexts/Airdrop/AirdropProvider.tsx
TypeScript error in /Users/rootulp/git/index-ui/src/contexts/Airdrop/AirdropProvider.tsx(2,26):
Could not find a declaration file for module 'web3-core'. '/Users/rootulp/git/index-ui/node_modules/web3-core/src/index.js' implicitly has an 'any' type.
Try `npm install @types/web3-core` if it exists or add a new declaration (.d.ts) file containing `declare module 'web3-core';` TS7016
1 | import React, { useState, useEffect } from 'react'
> 2 | import { provider } from 'web3-core'
| ^
3 | import { useCallback } from 'react'
4 | import BigNumber from 'bignumber.js'
5 |
I have a suspicion this is because the versions of web3 being pulled in by both projects are incompatible.
rootulp commented
Disregard, the above error seems unique to index-ui and may be resolved by IndexCoop/index-ui#364
rootulp commented
FWIW I no longer observe this error. This issue may be safe to close unless @cgewecke you have observed other compilation errors recently
AmagiDDmxh commented
Failed to compile.
./node_modules/set.js/src/api/DebtIssuanceAPI.ts:22:30
Type error: Could not find a declaration file for module '@setprotocol/set-protocol-v2/dist/utils/constants'. '/Users/amagi/dev/jj-web3-fe/node_modules/@setprotocol/set-protocol-v2/dist/utils/constants.js' implicitly has an 'any' type.
If the '@setprotocol/set-protocol-v2' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module '@setprotocol/set-protocol-v2/dist/utils/constants';`
20 | import { Provider } from '@ethersproject/providers';
21 | import { Address } from '@setprotocol/set-protocol-v2/utils/types';
> 22 | import { ADDRESS_ZERO } from '@setprotocol/set-protocol-v2/dist/utils/constants';
| ^
23 | import { TransactionOverrides } from '@setprotocol/set-protocol-v2/dist/typechain';
24 | import { BigNumber } from 'ethers/lib/ethers';
25 |
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Experience this on the newer version during compilation on tsbuild.
AmagiDDmxh commented
Failed to compile. ./node_modules/set.js/src/api/DebtIssuanceAPI.ts:22:30 Type error: Could not find a declaration file for module '@setprotocol/set-protocol-v2/dist/utils/constants'. '/Users/amagi/dev/jj-web3-fe/node_modules/@setprotocol/set-protocol-v2/dist/utils/constants.js' implicitly has an 'any' type. If the '@setprotocol/set-protocol-v2' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module '@setprotocol/set-protocol-v2/dist/utils/constants';` 20 | import { Provider } from '@ethersproject/providers'; 21 | import { Address } from '@setprotocol/set-protocol-v2/utils/types'; > 22 | import { ADDRESS_ZERO } from '@setprotocol/set-protocol-v2/dist/utils/constants'; | ^ 23 | import { TransactionOverrides } from '@setprotocol/set-protocol-v2/dist/typechain'; 24 | import { BigNumber } from 'ethers/lib/ethers'; 25 | error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.Experience this on the newer version during compilation on tsbuild.
problem solved, it happened because I've used the wrong import like
import { Position as IPosition, SetDetails } from 'set.js/src/types'
but it should import from
import { Position as IPosition, SetDetails } from 'set.js/dist/types/src/types'