Skip to content

Commit 6f9fb98

Browse files
committed
fix: improve typings
1 parent 1547200 commit 6f9fb98

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/loader.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ import { TypeScriptCompileError } from "./typescript-compile-error.js";
88
type LoaderAsync = (filepath: string, content: string) => Promise<LoaderResult>;
99

1010
export function TypeScriptLoader(options?: JitiOptions): LoaderAsync {
11-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
1211
const loader: Jiti = createJiti("", { interopDefault: true, ...options });
13-
return async (path: string): Promise<unknown> => {
12+
return async (path: string, _content: string): Promise<LoaderResult> => {
1413
try {
15-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
16-
const result: { default?: unknown } = (await loader.import(path)) as any;
14+
const result = (await loader.import(path)) as { default?: unknown };
1715

1816
// `default` is used when exporting using export default, some modules
1917
// may still use `module.exports` or if in TS `export = `
@@ -32,12 +30,11 @@ export function TypeScriptLoader(options?: JitiOptions): LoaderAsync {
3230
* @deprecated use `TypeScriptLoader`
3331
*/
3432
export function TypeScriptLoaderSync(options?: JitiOptions): LoaderSync {
35-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
3633
const loader: Jiti = createJiti("", { interopDefault: true, ...options });
37-
return (path: string): unknown => {
34+
return (path: string, _content: string): LoaderResult => {
3835
try {
39-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-deprecated
40-
const result: { default?: unknown } = loader(path);
36+
// eslint-disable-next-line @typescript-eslint/no-deprecated
37+
const result = loader(path) as { default?: unknown };
4138

4239
// `default` is used when exporting using export default, some modules
4340
// may still use `module.exports` or if in TS `export = `

0 commit comments

Comments
 (0)