Bug Report
Use of the satisfies keyword changes the output of the compiler. Vitally important require statements are missing. Does not appear to happen when using tsc but only when invoking the compiler programmatically as is done by ts-loader from the WebPack project.
🔎 Search Terms
satisfies, webpack, ts-loader, 4.9
🕗 Version & Regression Information
This bug only occurs when using the satisfies keyword.
⏯ Playground Link
Unable to reproduce with Playground so here is a repo showing the issue:
https://github.com/cjdell/typescript-satisfies-missing-modules-references-bug
Also another repo showing the original discovery of the bug including a working WebPack setup and ts-loader plugin:
https://github.com/cjdell/ts-loader-satisfies-bug
💻 Code
Note: This is fully demonstrated in the above GitHub repo.
import { z } from "zod";
import { isValid } from "./lib";
interface MyObject {
name: string;
}
export const MyObjectSchema = z.object({
name: z.string().refine(isValid),
}) satisfies z.ZodSchema<MyObject>; // Removing the `satisfies` keyword will change the output of the compiler
console.log(MyObjectSchema.parse({ name: 'foo' }));
Output with satisfies:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MyObjectSchema = void 0;
exports.MyObjectSchema = zod_1.z.object({
name: zod_1.z.string().refine(lib_1.isValid),
});
console.log(exports.MyObjectSchema.parse({ name: 'foo' }));
Output without satisfies:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MyObjectSchema = void 0;
const zod_1 = require("zod"); // THIS IS MISSING FROM ABOVE
const lib_1 = require("./lib"); // THIS IS MISSING FROM ABOVE
exports.MyObjectSchema = zod_1.z.object({
name: zod_1.z.string().refine(lib_1.isValid),
});
console.log(exports.MyObjectSchema.parse({ name: 'foo' }));
🙁 Actual behavior
As with above, using the satisfies keyword results in missing require statements.
🙂 Expected behavior
I expect the use of the satisfies keyword to have no effect on the compiler's outputted JavaScript.
Bug Report
Use of the
satisfieskeyword changes the output of the compiler. Vitally importantrequirestatements are missing. Does not appear to happen when usingtscbut only when invoking the compiler programmatically as is done byts-loaderfrom the WebPack project.🔎 Search Terms
satisfies, webpack, ts-loader, 4.9
🕗 Version & Regression Information
This bug only occurs when using the
satisfieskeyword.⏯ Playground Link
Unable to reproduce with Playground so here is a repo showing the issue:
https://github.com/cjdell/typescript-satisfies-missing-modules-references-bug
Also another repo showing the original discovery of the bug including a working WebPack setup and
ts-loaderplugin:https://github.com/cjdell/ts-loader-satisfies-bug
💻 Code
Note: This is fully demonstrated in the above GitHub repo.
Output with
satisfies:Output without
satisfies:🙁 Actual behavior
As with above, using the
satisfieskeyword results in missingrequirestatements.🙂 Expected behavior
I expect the use of the
satisfieskeyword to have no effect on the compiler's outputted JavaScript.