DefinitelyTyped/types/uid-generator
Kyle Chine 33e4ecd2fc Bugfix: Change the Export Method of UIDGenerator Class from Named-Export to Default-Export - @types/uid-generator (#39672)
* bugfix: class should be exported default

* bugfix: test failure

* temp

* also export interfaces

* syntax error fix

* syntax error fix

* syntax error fix

* syntax error fix

* syntax error fix

* syntax error fix

* syntax error fix

* syntax error fix

* syntax error fix

* syntax error fix

* index.d.ts done

* Bugfix: Change the Export Method of UIDGenerator Class from Named-Export to Default-Export

Motivation

In the original package (uid-generator), the class is exported by Default-Export:

  module.exports = UIDGenerator;

But in the current version of the type definition, the class is exported by Named-Export:

  export const UIDGenerator: UIDGeneratorConstructor;

Which leads to a piece of wrong JavaScript code after compilation:

  const uid_generator_1 = require("uid-generator");
  const uidgen = new uid_generator_1.UIDGenerator(bitLength);

The correct piece should be:

  const uid_generator_1 = require("uid-generator");
  const uidgen = new uid_generator_1(bitLength);

So I feel it may be necessary to fix this.

Fixed List

1. Interface Renaming

UIDGenerator            -> UIDGeneratorInstance
UIDGeneratorConstructor -> UIDGeneratorClass

In the current version, the name UIDGenerator used as both the name of the interface and the class, which may leads to confusion.
So I give them a little bit more clear names.

2. Default-Export UIDGenerator

3. UIDGeneratorInstance.generate(call-back): Error Parameter Added

In the orginal (uid-generator) package, the call-back function also accepts an error parameter. And when error did triggered, uid parameter may be optional.

4. Corresponding updates in test script

* syntax fix

* add target es2015

* Update types/uid-generator/tsconfig.json

Remove useless spaces.

Co-Authored-By: Emrio <emrio@emrio.fr>

* ES2015 to es6

* Restore to last time test-passed

"target":            "ES2015",

* Remove extra spaces

"target": "es6"

* Update types/uid-generator/index.d.ts

Remove the ? from uid parameter.

Co-Authored-By: Emrio <emrio@emrio.fr>

* Update types/uid-generator/uid-generator-tests.ts

uid must be string now.

Co-Authored-By: Emrio <emrio@emrio.fr>

* uid required now

* Remove target option

* add target:es6
2019-11-01 09:02:41 -07:00
..
index.d.ts
tsconfig.json
tslint.json
uid-generator-tests.ts