Skip to content

Commit 058d8cb

Browse files
authoredJul 8, 2023
fix: modernize type declarations (#299)
1 parent 4ed94f9 commit 058d8cb

File tree

1 file changed

+25
-41
lines changed

1 file changed

+25
-41
lines changed
 

‎index.d.ts

+25-41
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,33 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22

3-
declare namespace sortPackageJson {
4-
interface SortPackageJsonFn {
5-
/**
6-
* Sort packageJson object.
7-
*
8-
* @param packageJson - A packageJson
9-
* @param options - An options object
10-
* @returns Sorted packageJson object
11-
*/
12-
<T extends Record<any, any>>(packageJson: T, options?: Options): T
3+
type ComparatorFunction = (left: string, right: string) => number
134

14-
/**
15-
* Sort packageJson string.
16-
*
17-
* @param packageJson - A packageJson string.
18-
* @param options - An options object
19-
* @returns Sorted packageJson string.
20-
*/
21-
(packageJson: string, options?: Options): string
22-
}
23-
24-
type ComparatorFunction = (left: string, right: string) => number
25-
26-
function sortObjectBy<T extends Record<any, any>>(
27-
comparator?: string[],
28-
deep?: boolean,
29-
): (x: T) => T
30-
31-
interface Field {
32-
readonly key: string
33-
over?<T extends Record<any, any>>(x: T): T
34-
}
35-
36-
interface Options {
37-
readonly sortOrder?: readonly string[] | ComparatorFunction
38-
}
5+
interface Options {
6+
readonly sortOrder?: readonly string[] | ComparatorFunction
397
}
408

41-
interface sortPackageJsonExports extends sortPackageJson.SortPackageJsonFn {
42-
readonly default: sortPackageJson.SortPackageJsonFn
43-
readonly sortPackageJson: sortPackageJson.SortPackageJsonFn
44-
readonly sortOrder: string[]
9+
interface SortPackageJson {
10+
/**
11+
* Sort packageJson object.
12+
*
13+
* @param packageJson - A packageJson
14+
* @param options - An options object
15+
* @returns Sorted packageJson object
16+
*/
17+
<T extends Record<any, any>>(packageJson: T, options?: Options): T
18+
19+
/**
20+
* Sort packageJson string.
21+
*
22+
* @param packageJson - A packageJson string.
23+
* @param options - An options object
24+
* @returns Sorted packageJson string.
25+
*/
26+
(packageJson: string, options?: Options): string
4527
}
4628

47-
declare const sortPackageJsonExports: sortPackageJsonExports
29+
declare const sortPackageJsonDefault: SortPackageJson
30+
export default sortPackageJsonDefault
4831

49-
export = sortPackageJsonExports
32+
export const sortPackageJson: SortPackageJson
33+
export const sortOrder: string[]

0 commit comments

Comments
 (0)
Please sign in to comment.