Skip to content

Commit 572e1e9

Browse files
committed
Improve the TypeScript types
1 parent 3f9f85c commit 572e1e9

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

index.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
export type Replacer = (key: string, value: any) => number | string | boolean | object | null | undefined;
1+
export type Replacer = (this: unknown, key: string, value: unknown) => unknown;
22
export type SortKeys = (a: string, b: string) => number;
3-
export type JSONStringifyable = object | number | string | boolean;
3+
export type JSONStringifyable = string | number | boolean | null | object;
44

55
export interface Options {
66
/**
77
* Indentation as a string or number of spaces. Pass in null for no formatting.
88
*
99
* @default '\t'
1010
*/
11-
indent?: string | number | null;
11+
readonly indent?: string | number | null;
1212

1313
/**
1414
* Detect indentation automatically if the file exists.
1515
*
1616
* @default false
1717
*/
18-
detectIndent?: boolean;
18+
readonly detectIndent?: boolean;
1919

2020
/**
2121
* Sort the keys recursively. Optionally pass in a compare function.
2222
*
2323
* @default false
2424
*/
25-
sortKeys?: boolean | SortKeys;
25+
readonly sortKeys?: boolean | SortKeys;
2626

2727
/**
2828
* Passed into `JSON.stringify`.
2929
*/
30-
replacer?: Replacer | Array<number | string>;
30+
readonly replacer?: Replacer | Array<number | string>;
3131

3232
/**
3333
* Mode used when writing the file.
3434
*
3535
* @default 0o666
3636
*/
37-
mode?: number;
37+
readonly mode?: number;
3838
}
3939

4040
/**

index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ const mainSync = (filePath, data, options) => {
4949
if (options.detectIndent) {
5050
try {
5151
const file = fs.readFileSync(filePath, 'utf8');
52-
// eslint-disable-next-line prefer-destructuring
5352
indent = detectIndent(file).indent;
5453
} catch (error) {
5554
if (error.code !== 'ENOENT') {

0 commit comments

Comments
 (0)