Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5148

Adopt typescript 5 and related dependencies

    • 2
    • Not Needed
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Use Case

      Typescript 5.0

       @types/node                       ^18.11.19  →  ^18.15.11
       @typescript-eslint/eslint-plugin    ^5.55.0  →    ^5.57.0
       @typescript-eslint/parser           ^5.55.0  →    ^5.57.0
       eslint                              ^8.36.0  →    ^8.37.0
       eslint-config-prettier               ^8.7.0  →     ^8.8.0
       prettier                             ^2.8.4  →     ^2.8.7
       tsd                                 ^0.27.0  →    ^0.28.1
       typescript                           ^4.9.5  →     ^5.0.2
      

      User Impact

      None

      Dev Impact

      Faster build times

      Acceptance Criteria

      • Apply the following to the BSON repo as well.

      Implementation Requirements

      This type narrowing issue needs correcting, both Int32 instances and numbers have a .valueOf() function we could invoke so we can remove the the instanceof checking. Which we should not be using instanceof anyway.

      src/cmap/connect.ts(80,5): error TS2365: Operator '>=' cannot be applied to types 'number | Int32' and 'number'.
      src/cmap/connect.ts(84,5): error TS2365: Operator '<=' cannot be applied to types 'number | Int32' and 'number'.
      

      This option is deprecated, we can ignore the deprecation but it is going to be removed in a future minor version, might as well make the removal now.

      tsconfig.json(21,5): error TS5101: Option 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
      

      In order to continue enforcing the type indicator be used in front of type only imports, we need to start using eslint instead.
      https://typescript-eslint.io/rules/consistent-type-imports

      "@typescript-eslint/consistent-type-imports": [
                "error",
                {
                  "prefer": "type-imports",
                  "disallowTypeAnnotations": false,
                  "fixStyle": "inline-type-imports"
                }
              ],
      

      This will cause a reformat across many imports that didn't follow the rule we thought importsNotUsedAsValues was applying.

      Testing Requirements

      • Our typescript version matrix should be coverage enough.

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: