-
-
Notifications
You must be signed in to change notification settings - Fork 9
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 (#5)
- Loading branch information
1 parent
45996f2
commit 20dba2c
Showing
4 changed files
with
22 additions
and
18 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,19 +1,22 @@ | ||
declare const unusedFilename: { | ||
/** | ||
* Get an unused filename by appending a number if it exists: `file.txt` → `file (1).txt`. | ||
* | ||
* @param filePath - The path to check for filename collision. | ||
* @returns Either the original `filename` or the `filename` appended with a number. | ||
*/ | ||
Get an unused filename by appending a number if it exists: `file.txt` → `file (1).txt`. | ||
@param filePath - The path to check for filename collision. | ||
@returns Either the original `filename` or the `filename` appended with a number. | ||
*/ | ||
(filePath: string): Promise<string>; | ||
|
||
/** | ||
* Synchronously get an unused filename by appending a number if it exists: `file.txt` → `file (1).txt`. | ||
* | ||
* @param filePath - The path to check for filename collision. | ||
* @returns Either the original `filename` or the `filename` appended with a number. | ||
*/ | ||
Synchronously get an unused filename by appending a number if it exists: `file.txt` → `file (1).txt`. | ||
@param filePath - The path to check for filename collision. | ||
@returns Either the original `filename` or the `filename` appended with a number. | ||
*/ | ||
sync(filePath: string): string; | ||
} | ||
|
||
export default unusedFilename; | ||
// TODO: Remove this for the next major release | ||
default: typeof unusedFilename; | ||
}; | ||
|
||
export = unusedFilename; |
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,5 +1,5 @@ | ||
import {expectType} from 'tsd-check'; | ||
import unusedFilename from '.'; | ||
import {expectType} from 'tsd'; | ||
import unusedFilename = require('.'); | ||
|
||
expectType<Promise<string>>(unusedFilename('rainbow.txt')); | ||
expectType<string>(unusedFilename.sync('rainbow.txt')); |
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