Browse Source

Refactor TypeScript definition to CommonJS compatible export (#4)

master
Dimitri Benin 6 years ago
committed by Sindre Sorhus
parent
commit
6496614574
  1. 36
      index.d.ts
  2. 1
      index.js
  3. 4
      index.test-d.ts
  4. 10
      package.json

36
index.d.ts

@ -1,13 +1,23 @@
/**
* Check if `input` is a ES2015 promise.
*
* @param input - Value to be checked.
*
* @example
*
* import isPromise from 'p-is-promise';
*
* isPromise(Promise.resolve('🦄'));
* //=> true
*/
export default function(input: unknown): input is Promise<unknown>;
declare const pIsPromise: {
/**
Check if `input` is a ES2015 promise.
@param input - Value to be checked.
@example
```
import isPromise = require('p-is-promise');
isPromise(Promise.resolve('🦄'));
//=> true
```
*/
(input: unknown): input is Promise<unknown>;
// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function pIsPromise(input: unknown): input is Promise<unknown>;
// export = pIsPromise;
default: typeof pIsPromise;
};
export = pIsPromise;

1
index.js

@ -11,4 +11,5 @@ const isPromise = input => (
);
module.exports = isPromise;
// TODO: Remove this for the next major release
module.exports.default = isPromise;

4
index.test-d.ts

@ -1,5 +1,5 @@
import {expectType} from 'tsd-check';
import isPromise from '.';
import {expectType} from 'tsd';
import isPromise = require('.');
expectType<boolean>(isPromise('🦄'));

10
package.json

@ -13,7 +13,7 @@
"node": ">=6"
},
"scripts": {
"test": "xo && ava && tsd-check"
"test": "xo && ava && tsd"
},
"files": [
"index.js",
@ -34,9 +34,9 @@
"bluebird"
],
"devDependencies": {
"ava": "^0.25.0",
"bluebird": "^3.4.6",
"tsd-check": "^0.2.1",
"xo": "^0.23.0"
"ava": "^1.4.1",
"bluebird": "^3.5.4",
"tsd": "^0.7.2",
"xo": "^0.24.0"
}
}

Loading…
Cancel
Save