Reputation: 6715
I am using TypeScript and creating an API using nestjs and typeorm. Some of the modules in the project are made reusable by extracting them into its own node module. This is causing the Repository
type in the external module to not be the same type as the Repository
type inside the original package. So when using the external module I get the error
Argument of type 'import("/Users/user/project/node_modules/typeorm/repository/Repository")
.Repository<import("/Users/project/src/user/user.entity").User>'
is not assignable to parameter of type
'import("/Users/user/my-module/node_modules/typeorm/repository/Repository")
.Repository<import("/Users/project/src/user/user.entity").User>'.
The typeorm package is listed as a peerDependency in the node package so it should always be the same.
Upvotes: 2
Views: 184
Reputation: 60347
Your external library seems to have its own type definitions. In this thread, it is suggested to map imports to a folder under node_modules
manually in your package.json
:
"paths": {
"typeorm": ["node_modules/typeorm"],
"typeorm/*": ["node_modules/typeorm/*"]
}
This might only be an issue when using npm link
.
Upvotes: 2