Answer the question
In order to leave comments, you need to log in
How can I force tsc to use the types of packets it checks instead of the types of its invocation site?
Good day.
Faced a confusing situation. There are several repositories: one main, and several shared libraries that are installed as node modules and linked locally using yarn link. Typechecking is done using the tsc utility.
To paint the picture, let's have a Vault repository that uses the Utils library. Utils has dayjs installed, which is a good lib for working with dates. She adds her type declarations, everything is ok. I use the built-in Dayjs type in some cases to operate on a given object.
The problem is this: when we run yarn tsc inside Utils to check the correct types of Utils itself, everything works, tsc sees the types from the dayjs library. And when I run tsc inside Vault, it fails with the message "cannot find type Dayjs", and refers to a line where I'm using one of the Utils package modules. In Vault itself, the dayjs library and the Dayjs type are not used anywhere!
In other words, tsc crawls into another repository and checks types there, but using declarations from the project in which it was called.
The solution in the forehead is to install the dayjs lib in the Vault. I'll resort as a last resort, because Vault uses a wrapper from Utils to work with the date.
I hope I have explained the problem clearly. Who faced? How to solve the problem?
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
In Vault itself, the dayjs library and the Dayjs type are not used anywhere!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question