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

Missing function overload type for `EJSON.stringify`

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • bson-4.2.1
    • Affects Version/s: bson-4.2.0
    • Component/s: BSON
    • Labels:

      Hi,

      When using TypeScript overload, the last type (the one used for the implementation) is not exported in the `d.ts` file. Because of this there are only two signature for the `EJSON.stringify` function:  

      export function stringify(value: SerializableTypes): string;
      export function stringify(value: SerializableTypes, options?: EJSON.Options): string;

       

       To fix this, you need 3 function overloads (plus the implementation signature):

      export function stringify(value: SerializableTypes): string;
      export function stringify(value: SerializableTypes, options?: EJSON.Options): string;
      export function stringify(  value: SerializableTypes,  replacer?: (number | string)[] | ((this: any, key: string, value: any) => any),  space?: string | number,  options?: EJSON.Options): string;
      export function stringify(  value: SerializableTypes,  replacer?: (number | string)[] | ((this: any, key: string, value: any) => any) | EJSON.Options,  space?: string | number,  options?: EJSON.Options): string {
        // ...
      }

       

            Assignee:
            thomas.reggi@mongodb.com Thomas Reggi (Inactive)
            Reporter:
            etienne@lereacteur.io Etienne Dldc
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: