Skip to content

Commit eabc29d

Browse files
authored
fix: types for loadConfig and add more tests (#2123)
1 parent 52c0947 commit eabc29d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/svgo-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export * from './svgo.js';
3737
* You can also specify relative or absolute path and customize current working
3838
* directory.
3939
*
40-
* @type {<T extends string>(configFile?: T | null, cwd?: string) => Promise<T extends string ? import('./svgo.js').Config : import('./svgo.js').Config | null>}
40+
* @type {<T extends string | null>(configFile?: T, cwd?: string) => Promise<T extends string ? import('./svgo.js').Config : import('./svgo.js').Config | null>}
4141
*/
4242
export const loadConfig = async (configFile, cwd = process.cwd()) => {
4343
if (configFile != null) {

test-d/lib/svgo-node.test-d.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import { expectType, expectAssignable } from 'tsd';
2-
import { DataUri, Output, optimize } from '../../types/lib/svgo-node.js';
2+
import {
3+
type Config,
4+
type DataUri,
5+
type Output,
6+
loadConfig,
7+
optimize,
8+
} from '../../types/lib/svgo-node.js';
39

410
expectType<Output>(optimize('<svg></svg>'));
511
expectAssignable<DataUri>('enc');
12+
13+
expectType<Promise<Config | null>>(loadConfig());
14+
expectType<Promise<Config | null>>(loadConfig(undefined));
15+
expectType<Promise<Config | null>>(loadConfig(null));
16+
expectType<Promise<Config>>(loadConfig('svgo.config.js'));

0 commit comments

Comments
 (0)