Skip to content

Commit

Permalink
Require Node.js 8, add TypeScript definition (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
BendingBender authored and sindresorhus committed May 2, 2019
1 parent 1757b07 commit 976c7ba
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- '12'
- '10'
- '8'
- '6'
84 changes: 84 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import yes = require('./yes.json');
import no = require('./no.json');

declare const yesNoWords: {
/**
Yes like words.
@example
```
import yesNoWords = require('yes-no-words');
yesNoWords.yes;
//=> ['Absolutely', 'Ack', …]
```
*/
readonly yes: Readonly<typeof yes>;

/**
No like words.
@example
```
import yesNoWords = require('yes-no-words');
yesNoWords.no;
//=> ['Absolutely not', 'Ahhh nah', …]
```
*/
readonly no: Readonly<typeof no>;

/**
Both yes and no like words.
@example
```
import yesNoWords = require('yes-no-words');
yesNoWords.all;
//=> ['Absolutely', 'Absolutely not', 'Ack', …]
```
*/
readonly all: Readonly<typeof yes> & Readonly<typeof no>;

/**
Random yes like words.
@example
```
import yesNoWords = require('yes-no-words');
yesNoWords.yesRandom();
//=> 'Yisss'
```
*/
yesRandom(): string;

/**
Random no like words.
@example
```
import yesNoWords = require('yes-no-words');
yesNoWords.noRandom();
//=> 'Forget it'
```
*/
noRandom(): string;

/**
Random yes or no like words.
@example
```
import yesNoWords = require('yes-no-words');
yesNoWords.allRandom();
//=> 'NEIN NEIN NEIN'
```
*/
allRandom(): string;
};

export = yesNoWords;
9 changes: 9 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {expectType} from 'tsd';
import yesNoWords = require('.');

expectType<readonly string[]>(yesNoWords.yes);
expectType<readonly string[]>(yesNoWords.no);
expectType<readonly string[]>(yesNoWords.all);
expectType<string>(yesNoWords.yesRandom());
expectType<string>(yesNoWords.noRandom());
expectType<string>(yesNoWords.allRandom());
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
"yes-no": "cli.js"
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"scripts": {
"test": "xo && ava"
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts",
"cli.js",
"yes.json",
"no.json"
Expand All @@ -44,10 +45,16 @@
],
"dependencies": {
"meow": "^5.0.0",
"unique-random-array": "^1.0.0"
"unique-random-array": "^2.0.0"
},
"devDependencies": {
"ava": "^0.25.0",
"xo": "^0.23.0"
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
},
"tsd": {
"compilerOptions": {
"resolveJsonModule": true
}
}
}
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,37 @@ yesNoWords.yesRandom();

### .yes

Type: `array`
Type: `string[]`

Yes like words.

### .no

Type: `array`
Type: `string[]`

No like words.

### .all

Type: `array`
Type: `string[]`

Both yes and no like words.

### .yesRandom()

Type: `function`
Type: `Function`

Random yes like words.

### .noRandom()

Type: `function`
Type: `Function`

Random no like words.

### .allRandom()

Type: `function`
Type: `Function`

Random yes or no like words.

Expand Down

0 comments on commit 976c7ba

Please sign in to comment.