Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor TypeScript definition to CommonJS compatible export #3

Merged
merged 1 commit into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
/**
* Capitalize every word in a string: `unicorn cake` → `Unicorn Cake`.
*
* @param input - The string to titleize.
*/
export default function titleize(input: string): string;
declare const titleize: {
/**
Capitalize every word in a string: `unicorn cake` → `Unicorn Cake`.

@param input - The string to titleize.

@example
```
import titleize = require('titleize');

titleize('foo bar');
//=> 'Foo Bar'

titleize('foo-bar');
//=> 'Foo-Bar'
```
*/
(input: string): string;

// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function titleize(input: string): string;
// export = titleize;
default: typeof titleize;
};

export = titleize;
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ const titleize = input => {
};

module.exports = titleize;
// TODO: Remove this for the next major release
module.exports.default = titleize;
4 changes: 2 additions & 2 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expectType} from 'tsd-check';
import titleize from '.';
import {expectType} from 'tsd';
import titleize = require('.');

expectType<string>(titleize('foo bar'));
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"node": ">=6"
},
"scripts": {
"test": "xo && ava && tsd-check"
"test": "xo && ava && tsd"
},
"files": [
"index.js",
Expand All @@ -32,8 +32,8 @@
"convert"
],
"devDependencies": {
"ava": "^1.2.1",
"tsd-check": "^0.3.0",
"ava": "^1.4.1",
"tsd": "^0.7.1",
"xo": "^0.24.0"
}
}