diff --git a/lib/types.d.ts b/lib/types.d.ts index e5cf6f53..4efb2b56 100644 --- a/lib/types.d.ts +++ b/lib/types.d.ts @@ -18,10 +18,10 @@ export interface Jiti extends NodeRequire { * * If you need the default export of module, you can use `jiti.import(id, { default: true })` as shortcut to `mod?.default ?? mod`. */ - import( + import( id: string, opts?: JitiResolveOptions & { default?: true }, - ): Promise; + ): Promise; /** * Resolve with ESM import conditions. diff --git a/src/jiti.ts b/src/jiti.ts index 4c5ff941..b4d1103d 100644 --- a/src/jiti.ts +++ b/src/jiti.ts @@ -141,7 +141,10 @@ export default function createJiti( evalModule(source: string, options?: EvalModuleOptions) { return evalModule(ctx, source, options); }, - async import(id: string, opts?: JitiResolveOptions & { default?: true }) { + async import( + id: string, + opts?: JitiResolveOptions & { default?: true }, + ): Promise { const mod = await jitiRequire(ctx, id, { ...opts, async: true }); return opts?.default ? (mod?.default ?? mod) : mod; }, diff --git a/test/bun.test.ts b/test/bun.test.ts index 52c99caa..bcdb416e 100644 --- a/test/bun.test.ts +++ b/test/bun.test.ts @@ -47,10 +47,10 @@ test("hmr", async () => { let value; await writeFile(tmpFile, "export default 1"); - value = (await _jiti.import(tmpFile, { default: true })) as any; + value = await _jiti.import(tmpFile, { default: true }); expect(value).toBe(1); await writeFile(tmpFile, "export default 2"); - value = (await _jiti.import(tmpFile, { default: true })) as any; + value = await _jiti.import(tmpFile, { default: true }); expect(value).toBe(2); });