Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor TypeScript definition to CommonJS compatible export (#6)
- Loading branch information
1 parent
7d5a88f
commit f43ce03
Showing
4 changed files
with
27 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
/** | ||
Get the visual width of the widest line in a string - the number of columns required to display it. | ||
@example | ||
``` | ||
import widestLine from 'widest-line'; | ||
widestLine('古\n\u001B[1m@\u001B[22m'); | ||
//=> 2 | ||
``` | ||
*/ | ||
export default function widestLine(input: string): number; | ||
declare const widestLine: { | ||
/** | ||
Get the visual width of the widest line in a string - the number of columns required to display it. | ||
@example | ||
``` | ||
import widestLine = require('widest-line'); | ||
widestLine('古\n\u001B[1m@\u001B[22m'); | ||
//=> 2 | ||
``` | ||
*/ | ||
(input: string): number; | ||
|
||
// TODO: remove this in the next major version, refactor definition to: | ||
// declare function widestLine(input: string): number; | ||
// export = widestLine; | ||
default: typeof widestLine; | ||
}; | ||
|
||
export = widestLine; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {expectType} from 'tsd-check'; | ||
import widestLine from '.'; | ||
import {expectType} from 'tsd'; | ||
import widestLine = require('.'); | ||
|
||
expectType<number>(widestLine('古\n\u001B[1m@\u001B[22m')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters