Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ function interopDefault(mod: any): any {
const defIsNil = def === null || def === undefined;
const defIsObj = defType === "object" || defType === "function";

if (defIsNil && mod instanceof Promise) {
// Hotfix for #388
return mod;
}

return new Proxy(mod, {
get(target, prop, receiver) {
if (prop === "__esModule") {
Expand Down
3 changes: 2 additions & 1 deletion test/__snapshots__/fixtures.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,6 @@ Decorator called with 1 arguments.
normalizeUserEntity: [Function: normalizeUserEntity]
}
}
child"
child
promise resolved"
`;
1 change: 1 addition & 0 deletions test/fixtures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe("fixtures", async () => {
)
.replace("internal/errors:496", "events:276")
.replace(" ^", " ^")
.replace(/ExperimentalWarning: CommonJS module/, "")
// eslint-disable-next-line no-control-regex
.replace(/\u001B\[[\d;]*m/gu, "")
.trim()
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/typescript/def-promise.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// https://github.com/unjs/jiti/issues/388
export = Promise.resolve("promise resolved");
3 changes: 3 additions & 0 deletions test/fixtures/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import test, { type FeedService as _FeedService } from "./test";
import Clazz from "./decorators";
import { test as satisfiesTest } from "./satisfies";
import { child } from "./parent.mjs";
// @ts-expect-error (needs allowImportingTsExtensions)
import defPromise from "./def-promise.cts";

export type { Test } from "./types";

console.log(test(), Clazz);
console.log(satisfiesTest());
console.log(child());
console.log(await defPromise);