question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add `typesVersion` with minimum TypeScript version

See original GitHub issue

Prerequisites

  • 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:

Screenshot 2022-10-05 at 20 58 43

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:closed
  • Created a year ago
  • Comments:17

github_iconTop GitHub Comments

2reactions
hxtreecommented, Oct 22, 2022

It appears, if a typesVersions were added to mongoose / package.json, probably similar to:

  "typesVersions": {
    ">=4.8.4": { "*": "./types/index.d.ts"] }
  }

It would produce the following error using the package with a unsupported version. And the error message appears to be improvable.

"'package.json' does not have a 'typesVersions' entry that matches version '{0}'."

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

1reaction
hxtreecommented, Oct 20, 2022

Oh although i had ts v4.8.4 installed it was still using v4.6.2 for compilation. That fixed it. Sry, Thank

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.

  "devDependencies": {
    "typescript": "4.8.4"
  },

This is a really obscure requirement to find, Perhaps the Typescript minimum version could be placed README or similar to help distribute this info?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found