You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
In a TypeScript project that uses a package that imports Mongoose, these errors will occur on build in a case-sensitive OS (e.g. Linux):
TS2688: Cannot find type definition file for 'mongoose/types/pipelinestage'.
TS2688: Cannot find type definition file for 'mongoose/types/error'.
TS2688: Cannot find type definition file for 'mongoose/types/connection'.
If the current behavior is a bug, please provide the steps to reproduce.
I'm working on a minimal repro, I will post it here when I'm done.
Here is what I think is going on: #11368, #11418, #11369 and split index.d.ts into separate PipelineStage, Connection, and Error type declaration files. These are referenced in index.d.ts with triple-slash directives:
Now, when I attempt to use example-package in another project, a bug In TypeScript (microsoft/TypeScript#45096) causes paths in triple-slash directives to be lowercased. This mean that the compiler sees
and looks for a declaration file at node_modules/mongoose/types/pipelinestage.d.ts. Since the real declaration file is PipelineStage.d.ts, on case-sensitive systems the compiler does not find any declaration file and throws an error. On case-insensitive systems the compiler finds the declaration file despite searching with the wrong case.
To work around the Typescript bug, I recommend using lower-case filenames for type declaration files: error.d.ts, pipeline-stage.d.ts, and connection.d.ts. I have tries this locally and confirmed that it fixes my project.
Note: I have tried using the forceConsistentCasingInFileNames option. It has no effect on this issue.
What is the expected behavior?
Projects that depend on packages that depend on Mongoose should compile without errors on a case-sensitive OS.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node: v14.18.2
Mongoose: v6.2.4 (issue is present in versions ^6.2.2)
MongoDB: 4.3.1
TypeScript: 4.4.3
The text was updated successfully, but these errors were encountered:
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
In a TypeScript project that uses a package that imports Mongoose, these errors will occur on build in a case-sensitive OS (e.g. Linux):
If the current behavior is a bug, please provide the steps to reproduce.
I'm working on a minimal repro, I will post it here when I'm done.
Here is what I think is going on:
#11368, #11418, #11369 and split
index.d.ts
into separate PipelineStage, Connection, and Error type declaration files. These are referenced inindex.d.ts
with triple-slash directives:When Typescript generates a type declaration file
example-package.d.ts
for my package that imports Mongoose, it adds this to the top of the file:Now, when I attempt to use
example-package
in another project, a bug In TypeScript (microsoft/TypeScript#45096) causes paths in triple-slash directives to be lowercased. This mean that the compiler seesand looks for a declaration file at
node_modules/mongoose/types/pipelinestage.d.ts
. Since the real declaration file isPipelineStage.d.ts
, on case-sensitive systems the compiler does not find any declaration file and throws an error. On case-insensitive systems the compiler finds the declaration file despite searching with the wrong case.To work around the Typescript bug, I recommend using lower-case filenames for type declaration files:
error.d.ts
,pipeline-stage.d.ts
, andconnection.d.ts
. I have tries this locally and confirmed that it fixes my project.Here is a similar issue that was traced to the above TypeScript bug: microsoft/TypeScript#45509
tsconfig.json:
Note: I have tried using the
forceConsistentCasingInFileNames
option. It has no effect on this issue.What is the expected behavior?
Projects that depend on packages that depend on Mongoose should compile without errors on a case-sensitive OS.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node:
v14.18.2
Mongoose:
v6.2.4
(issue is present in versions^6.2.2
)MongoDB:
4.3.1
TypeScript:
4.4.3
The text was updated successfully, but these errors were encountered: