Add `typesVersion` with minimum TypeScript version
See original GitHub issuePrerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Mongoose version
6.6.5
Node.js version
16.16.0
MongoDB server version
6.0.2 (not required)
Description
I’ve experienced an issue with mongoose above version 6.6.3
. When I try to build a project that uses mongoose in version 6.6.4
or higher I receive:
When I switched to 6.6.3
the issue does not occur. My TS config:
{
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src",
"esModuleInterop": true,
"lib": [
"es2021",
"dom"
],
"module": "commonjs",
"target": "es2021",
"moduleResolution": "node",
"allowJs": true,
"noImplicitAny": true,
"composite": true,
"skipLibCheck": true,
"sourceMap": true,
"strictNullChecks": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"include": [
"src/**/*"
]
}
}
As I briefly checked, the pointed places seem to be syntactically correct so the issue is a bit awkward for me. I’d be grateful for a hint if an issue is on my side.
Steps to Reproduce
Just run tsc --build
for a project that uses mongoose
.
Expected Behavior
The project is built correctly.
Issue Analytics
- State:
- Created a year ago
- Comments:17
Top Results From Across the Web
How to specify the minimum Typescript version for types in ...
You can support multiple typescript language versions in your ... Add a typesVersions key to package.json , with the following contents:
Read more >How to set up TypeScript
To do this, run npm install -g typescript . This will install the latest version (currently 4.9).
Read more >Documentation - TypeScript 4.5
Then from 4.5 onwards, you can update TypeScript and your dependency manager's lockfile will ensure that it uses the exact same version of...
Read more >Documentation - TypeScript 4.3
TypeScript 4.3 Release Notes. ... In fact, we've added syntax to interfaces/object types to support different reading/writing types on properties.
Read more >Documentation - TypeScript 3.9
TypeScript 3.9 Release Notes. ... The function's types declare that it takes two string s so that other TypeScript users can get type-checking...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It appears, if a
typesVersions
were added to mongoose / package.json, probably similar to:It would produce the following error using the package with a unsupported version. And the error message appears to be improvable.
References: https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#version-selection-with-typesversions https://github.com/microsoft/TypeScript/issues/32166 https://github.com/search?q=">%3D4.8.4"+filename%3Apackage.json+typesversions
I ran into the same issue. I had Typescript 4.8.4 installed globally but in a monorepo package.json there was 4.6.2, which needed to change to.
This is a really obscure requirement to find, Perhaps the Typescript minimum version could be placed README or similar to help distribute this info?