1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-29 20:21:14 +03:00

fix: types for loadConfig and add more tests (#2123)

This commit is contained in:
Seth Falco
2025-05-06 08:05:09 +01:00
committed by GitHub
parent 52c09479e9
commit eabc29d159
2 changed files with 13 additions and 2 deletions

View File

@ -37,7 +37,7 @@ export * from './svgo.js';
* You can also specify relative or absolute path and customize current working
* directory.
*
* @type {<T extends string>(configFile?: T | null, cwd?: string) => Promise<T extends string ? import('./svgo.js').Config : import('./svgo.js').Config | null>}
* @type {<T extends string | null>(configFile?: T, cwd?: string) => Promise<T extends string ? import('./svgo.js').Config : import('./svgo.js').Config | null>}
*/
export const loadConfig = async (configFile, cwd = process.cwd()) => {
if (configFile != null) {

View File

@ -1,5 +1,16 @@
import { expectType, expectAssignable } from 'tsd';
import { DataUri, Output, optimize } from '../../types/lib/svgo-node.js';
import {
type Config,
type DataUri,
type Output,
loadConfig,
optimize,
} from '../../types/lib/svgo-node.js';
expectType<Output>(optimize('<svg></svg>'));
expectAssignable<DataUri>('enc');
expectType<Promise<Config | null>>(loadConfig());
expectType<Promise<Config | null>>(loadConfig(undefined));
expectType<Promise<Config | null>>(loadConfig(null));
expectType<Promise<Config>>(loadConfig('svgo.config.js'));