We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
random
Related to: #1069 After several PRs including #1133, the bundle size is decreasing !!
So basic functions like is or assert is well tree-shaked.
is
assert
However, random generator is little bit hard to tree-shaking.
Here is why.
suppose you create a random function like this
import typia, { type tags } from "typia"; export const random = typia.createRandom<IMember>(); interface IMember { email: string & tags.Format<"email">; }
this is compiled like this.
const RandomGenerator = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, array, bigint, boolean, byte, date, datetime, duration, email, hostname, idnEmail, idnHostname, integer, ipv4, ipv6, iri, iriReference, jsonPointer, length, number, password, pattern, pick, regex, relativeJsonPointer, string, time, uri, uriReference, uriTemplate, url, uuid }, Symbol.toStringTag, { value: "Module" })); const random$2 = () => ({ generator: RandomGenerator, pick }); function random$1() { halt("random"); } const randomPure = /* @__PURE__ */ Object.assign( random$1, /* @__PURE__ */ random$2() ); function createRandom() { halt("createRandom"); } const createRandomPure = /* @__PURE__ */ Object.assign(createRandom, randomPure); function halt(name) { throw new Error(`Error on typia.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`); } const random = (generator) => { const $generator = createRandomPure.generator; const $ro0 = (_recursive = false, _depth = 0) => { var _a, _b; return { email: ((_b = (_a = $generator.customs) == null ? void 0 : _a.string) == null ? void 0 : _b.call(_a, [ { name: 'Format<"email">', kind: "format", value: "email" } ])) ?? (0, $generator.email)() }; }; return $ro0(); };
The implementation is here. https://github.com/ryoppippi/typia/blob/b09a027d958fff0e384d4b6cae16f362fa4d6887/src/functional/Namespace/index.ts?plain=1#L73-L76
If this random function will be an exports like this
export { generator, pick }
and generater call method should be random$2().generator.email ↓ random$2.generator.email
random$2().generator.email
random$2.generator.email
It is really great for tree-shaking.
I think this needs change APIs a little bit, and I don't know if I can tackle this change as I don't fully understand the API yet.
I also think that this should be included in v7 because this change is API level and users need re-compile
The text was updated successfully, but these errors were encountered:
This problem would be cleared fixed in the next v7 update, and it is coming. Only LLm schema features are left.
Sorry, something went wrong.
No branches or pull requests
Feature Request
Related to: #1069
After several PRs including #1133, the bundle size is decreasing !!
So basic functions like
is
orassert
is well tree-shaked.However, random generator is little bit hard to tree-shaking.
Here is why.
suppose you create a random function like this
this is compiled like this.
The implementation is here.
https://github.com/ryoppippi/typia/blob/b09a027d958fff0e384d4b6cae16f362fa4d6887/src/functional/Namespace/index.ts?plain=1#L73-L76
If this
random
function will be an exports like thisand generater call method should be
random$2().generator.email
↓
random$2.generator.email
It is really great for tree-shaking.
I think this needs change APIs a little bit, and I don't know if I can tackle this change as I don't fully understand the API yet.
I also think that this should be included in v7 because this change is API level and users need re-compile
The text was updated successfully, but these errors were encountered: