Skip to content

Commit 0e4155b

Browse files
committed
Fix ts2742 when resolving ts-common types
This error has been plaguing me for ages. It appears to be caused by the static inferred type of an io-ts codec depending on a type in a transitive dependency. Explicitly importing those transitive types seems to help, but that results in a bunch of unused imports, which is undesireable. I've had some success fixing it by doing two things: (1): Installing ts-common as a top level dep that's the same version as all transitive dependencies on it. (2): Reinstalling to allow npm to "dedupe" the package. This makes sure imports to ts-common resolve at the top level rather than transitively. However, with using lerna, deduping doesn't appear to work. But to make things even more confusing, this error cropped up only in tron-payments, but not in stellar-payments. Even though they're using identical package versions and similar imports. Then I stumbled across microsoft/TypeScript#29808 which describes a very similar issue. I ended up trying this commentors solution microsoft/TypeScript#29808 (comment) and that appeared to fix the issue. This isn't a perfect solution, but it's the best I've found. Ideally typescript should always generate portable declaration files, or at least resolve to the top level module when installed.
1 parent ab28a47 commit 0e4155b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

packages/tron-payments/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"outDir": "dist/lib",
66
"paths": {
77
"#/*": ["./src/*"],
8+
"@faast/ts-common": ["node_modules/@faast/ts-common"],
89
}
910
},
1011
"exclude": ["node_modules", "dist"]

0 commit comments

Comments
 (0)