1- import { expectType } from 'tsd' ;
2- import writeJsonFile = require( '.' ) ;
3- import { sync , Replacer , SortKeys } from '.' ;
1+ import { expectType , expectAssignable } from 'tsd' ;
2+ import { writeJsonFile , writeJsonFileSync , Replacer , SortKeys } from './index.js' ;
43
5- expectType < SortKeys > ( ( ) => 1 ) ;
6- expectType < SortKeys > ( ( a : string ) => a . length ) ;
7- expectType < SortKeys > ( ( a : string , b : string ) => a . length - b . length ) ;
4+ expectAssignable < SortKeys > ( ( ) => 1 ) ;
5+ expectAssignable < SortKeys > ( ( a : string ) => a . length ) ;
6+ expectAssignable < SortKeys > ( ( a : string , b : string ) => a . length - b . length ) ;
87
9- expectType < Replacer > ( ( ) => 1 ) ;
10- expectType < Replacer > ( ( ) => 'unicorn' ) ;
11- expectType < Replacer > ( ( ) => true ) ;
12- expectType < Replacer > ( ( ) => null ) ;
13- expectType < Replacer > ( ( ) => undefined ) ;
14- expectType < Replacer > ( ( ) => ( { unicorn : '🦄' } ) ) ;
15- expectType < Replacer > ( ( ) => [ 'unicorn' , 1 ] ) ;
16- expectType < Replacer > ( ( ) => ( ) => 'foo' ) ;
17- expectType < Replacer > ( ( key : string ) => key . toUpperCase ( ) ) ;
18- expectType < Replacer > ( ( key : string , value : string ) => ( key + value ) . toUpperCase ( ) ) ;
8+ expectAssignable < Replacer > ( ( ) => 1 ) ;
9+ expectAssignable < Replacer > ( ( ) => 'unicorn' ) ;
10+ expectAssignable < Replacer > ( ( ) => true ) ;
11+ expectAssignable < Replacer > ( ( ) => null ) ;
12+ expectAssignable < Replacer > ( ( ) => undefined ) ;
13+ expectAssignable < Replacer > ( ( ) => ( { unicorn : '🦄' } ) ) ;
14+ expectAssignable < Replacer > ( ( ) => [ 'unicorn' , 1 ] ) ;
15+ expectAssignable < Replacer > ( ( ) => ( ) => 'foo' ) ;
16+ expectAssignable < Replacer > ( ( key : string ) => key . toUpperCase ( ) ) ;
17+ expectAssignable < Replacer > ( ( key : string , value : unknown ) => ( key + ( value as string ) ) . toUpperCase ( ) ) ;
1918
2019expectType < Promise < void > > ( writeJsonFile ( 'unicorn.json' , { unicorn : '🦄' } ) ) ;
2120expectType < Promise < void > > ( writeJsonFile ( 'unicorn.json' , '🦄' ) ) ;
@@ -30,15 +29,15 @@ expectType<Promise<void>>(writeJsonFile('unicorn.json', {unicorn: '🦄'}, {sort
3029expectType < Promise < void > > ( writeJsonFile ( 'unicorn.json' , { unicorn : '🦄' } , { sortKeys : ( a : string , b : string ) => a . length - b . length } ) ) ;
3130expectType < Promise < void > > ( writeJsonFile ( 'unicorn.json' , { unicorn : '🦄' } , { sortKeys : true } ) ) ;
3231
33- expectType < void > ( sync ( 'unicorn.json' , { unicorn : '🦄' } ) ) ;
34- expectType < void > ( sync ( 'unicorn.json' , '🦄' ) ) ;
35- expectType < void > ( sync ( 'date.json' , new Date ( ) ) ) ;
36- expectType < void > ( sync ( 'unicorn.json' , { unicorn : '🦄' } , { detectIndent : true } ) ) ;
37- expectType < void > ( sync ( 'unicorn.json' , { unicorn : '🦄' } , { indent : ' ' } ) ) ;
38- expectType < void > ( sync ( 'unicorn.json' , { unicorn : '🦄' } , { indent : 4 } ) ) ;
39- expectType < void > ( sync ( 'unicorn.json' , { unicorn : '🦄' } , { mode : 0o666 } ) ) ;
40- expectType < void > ( sync ( 'unicorn.json' , { unicorn : '🦄' } , { replacer : [ 'unicorn' , 1 ] } ) ) ;
41- expectType < void > ( sync ( 'unicorn.json' , { unicorn : '🦄' } , { replacer : ( ) => 'unicorn' } ) ) ;
42- expectType < void > ( sync ( 'unicorn.json' , { unicorn : '🦄' } , { sortKeys : ( ) => - 1 } ) ) ;
43- expectType < void > ( sync ( 'unicorn.json' , { unicorn : '🦄' } , { sortKeys : ( a : string , b : string ) => a . length - b . length } ) ) ;
44- expectType < void > ( sync ( 'unicorn.json' , { unicorn : '🦄' } , { sortKeys : true } ) ) ;
32+ expectType < void > ( writeJsonFileSync ( 'unicorn.json' , { unicorn : '🦄' } ) ) ;
33+ expectType < void > ( writeJsonFileSync ( 'unicorn.json' , '🦄' ) ) ;
34+ expectType < void > ( writeJsonFileSync ( 'date.json' , new Date ( ) ) ) ;
35+ expectType < void > ( writeJsonFileSync ( 'unicorn.json' , { unicorn : '🦄' } , { detectIndent : true } ) ) ;
36+ expectType < void > ( writeJsonFileSync ( 'unicorn.json' , { unicorn : '🦄' } , { indent : ' ' } ) ) ;
37+ expectType < void > ( writeJsonFileSync ( 'unicorn.json' , { unicorn : '🦄' } , { indent : 4 } ) ) ;
38+ expectType < void > ( writeJsonFileSync ( 'unicorn.json' , { unicorn : '🦄' } , { mode : 0o666 } ) ) ;
39+ expectType < void > ( writeJsonFileSync ( 'unicorn.json' , { unicorn : '🦄' } , { replacer : [ 'unicorn' , 1 ] } ) ) ;
40+ expectType < void > ( writeJsonFileSync ( 'unicorn.json' , { unicorn : '🦄' } , { replacer : ( ) => 'unicorn' } ) ) ;
41+ expectType < void > ( writeJsonFileSync ( 'unicorn.json' , { unicorn : '🦄' } , { sortKeys : ( ) => - 1 } ) ) ;
42+ expectType < void > ( writeJsonFileSync ( 'unicorn.json' , { unicorn : '🦄' } , { sortKeys : ( a : string , b : string ) => a . length - b . length } ) ) ;
43+ expectType < void > ( writeJsonFileSync ( 'unicorn.json' , { unicorn : '🦄' } , { sortKeys : true } ) ) ;
0 commit comments