Skip to content

Commit

Permalink
Improve TypeScript declarations file (#660)
Browse files Browse the repository at this point in the history
* Improve TypeScript declarations file

Addresses but does not fully close #581

Proper way to import is now `import * as X from 'jimp'` wherein X can be
whatever the end-user wants, in most cases `Jimp`.

* Truly resolve declarations file

I have losely based this on knowledge gained from analyzing other
declarations files, primarily @types/better-sqlite3. Using this
formatting for declaration file allows for `import * as Jimp from
'jimp'` importing which is a proper way when using TypeScript as it
primarily recommends ES6 imports. It will require setting the
`allowSyntheticDefaultImports` compiler option to `true`, however this
is a very small issue as many packages on npm (including aforementioned
better-sqlite3) require this.

- Like previous commit this ensures we no longer need to use `import
Jimp = require('jimp'). As has been agreed upon, using `require` when
working with ES6 modules is just wrong in code style.

- Unlike previous commit no more ts-ignore, yay!

- It is maintainable. New types or interface come at the bottom and any
new or modifications to functions and constants go in the topmost
interface. We'll never have to touch the declared const or the export.
  • Loading branch information
hipstersmoothie committed Nov 28, 2018
1 parent 14055cf commit 466b65b
Showing 1 changed file with 511 additions and 549 deletions.
Loading

0 comments on commit 466b65b

Please sign in to comment.