typia 15.3.0 → 15.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,8 +6,8 @@ import { Resolved } from "@typia/interface";
6
6
  * files, boxed primitives and plain objects are rebuilt. Functions become
7
7
  * undefined; object properties with undefined results are omitted, while
8
8
  * arrays, sets and maps retain them. Weak collections throw. Cycles are not
9
- * tracked, and ordinary objects may invoke their own valueOf or property
10
- * getters.
9
+ * tracked, and ordinary objects may invoke a callable valueOf or property
10
+ * getters. A missing or non-callable valueOf is ordinary data.
11
11
  *
12
12
  * @evidence contracts/common.md#principled-implementation The clone walks the value and rebuilds arrays, sets, maps, boxed primitives, dates, regular expressions, typed arrays, buffers, data views, blobs, files and plain objects, turns functions into undefined, omits object properties whose cloned values are undefined while retaining such array/set/map results, and throws for weak collections. Native recognition checks intrinsic prototype accessors with `Reflect.apply` rather than trusting a supplied string tag or own getter; native clones use those captured accessors for their internal data. The ordinary-object branch invokes valueOf and clones its replacement when different, otherwise rebuilding enumerable own entries. Cycles are not tracked, so a cyclic value does not terminate.
13
13
  * @evidence contracts/common.md#clear-and-simple-design One entry function over a recognition function, a native cloner and a buffer range copier; the accessor captures are module-level constants because they are looked up once from the prototypes.
@@ -8,8 +8,8 @@ exports._plainCloneAny = void 0;
8
8
  * files, boxed primitives and plain objects are rebuilt. Functions become
9
9
  * undefined; object properties with undefined results are omitted, while
10
10
  * arrays, sets and maps retain them. Weak collections throw. Cycles are not
11
- * tracked, and ordinary objects may invoke their own valueOf or property
12
- * getters.
11
+ * tracked, and ordinary objects may invoke a callable valueOf or property
12
+ * getters. A missing or non-callable valueOf is ordinary data.
13
13
  *
14
14
  * @evidence contracts/common.md#principled-implementation The clone walks the value and rebuilds arrays, sets, maps, boxed primitives, dates, regular expressions, typed arrays, buffers, data views, blobs, files and plain objects, turns functions into undefined, omits object properties whose cloned values are undefined while retaining such array/set/map results, and throws for weak collections. Native recognition checks intrinsic prototype accessors with `Reflect.apply` rather than trusting a supplied string tag or own getter; native clones use those captured accessors for their internal data. The ordinary-object branch invokes valueOf and clones its replacement when different, otherwise rebuilding enumerable own entries. Cycles are not tracked, so a cyclic value does not terminate.
15
15
  * @evidence contracts/common.md#clear-and-simple-design One entry function over a recognition function, a native cloner and a buffer range copier; the accessor captures are module-level constants because they are looked up once from the prototypes.
@@ -102,9 +102,12 @@ const cloneMain = (value) => {
102
102
  else if (value instanceof WeakSet || value instanceof WeakMap)
103
103
  throw new Error("WeakSet and WeakMap are not supported");
104
104
  else {
105
- const primitive = value.valueOf();
106
- if (primitive !== value)
107
- return cloneMain(primitive);
105
+ const valueOf = value.valueOf;
106
+ if (typeof valueOf === "function") {
107
+ const primitive = Reflect.apply(valueOf, value, []);
108
+ if (primitive !== value)
109
+ return cloneMain(primitive);
110
+ }
108
111
  return Object.fromEntries(Object.entries(value)
109
112
  .map(([k, v]) => [k, cloneMain(v)])
110
113
  .filter(([, v]) => v !== undefined));
@@ -1 +1 @@
1
- {"version":3,"file":"_plainCloneAny.js","sources":["../../src/internal/_plainCloneAny.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;GAcG;AACI,MAAM,cAAc,GAAG,CAAI,KAAQ,EAAe,EAAE,CACzD,SAAS,CAAC,KAAK,CAAgB,CAAC;AADrB,QAAA,cAAc,GAAd,cAAc,CACO;AAElC,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AACxC,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;AACjD,MAAM,MAAM,GAAG,CAAC,SAAiB,EAAE,GAAgB,EAAmB,EAAE,CACtE,MAAM,CAAC,wBAAwB,CAAC,SAAS,EAAE,GAAG,CAAE,CAAC,GAAI,CAAC;AACxD,MAAM,IAAI,GAAG,CAAI,QAAuB,EAAE,KAAa,EAAK,EAAE,CAC5D,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAM,CAAC;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AAO,iBAAiB,KAAK,WAAW;YAC1C,MAAM,IAAI,SAAS,CAAC,oCAAoC,CAAC,CAAC;QAC5D,MAAM,GAAG,IAAI,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC7C,CAAC;SAAM,CAAC;QACN,IAAI,CAAS,qBAAqB,EAAE,KAAK,CAAC,CAAC;QAC3C,MAAM,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IAC1E,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -6,8 +6,8 @@
6
6
  * files, boxed primitives and plain objects are rebuilt. Functions become
7
7
  * undefined; object properties with undefined results are omitted, while
8
8
  * arrays, sets and maps retain them. Weak collections throw. Cycles are not
9
- * tracked, and ordinary objects may invoke their own valueOf or property
10
- * getters.
9
+ * tracked, and ordinary objects may invoke a callable valueOf or property
10
+ * getters. A missing or non-callable valueOf is ordinary data.
11
11
  *
12
12
  * @evidence contracts/common.md#principled-implementation The clone walks the value and rebuilds arrays, sets, maps, boxed primitives, dates, regular expressions, typed arrays, buffers, data views, blobs, files and plain objects, turns functions into undefined, omits object properties whose cloned values are undefined while retaining such array/set/map results, and throws for weak collections. Native recognition checks intrinsic prototype accessors with `Reflect.apply` rather than trusting a supplied string tag or own getter; native clones use those captured accessors for their internal data. The ordinary-object branch invokes valueOf and clones its replacement when different, otherwise rebuilding enumerable own entries. Cycles are not tracked, so a cyclic value does not terminate.
13
13
  * @evidence contracts/common.md#clear-and-simple-design One entry function over a recognition function, a native cloner and a buffer range copier; the accessor captures are module-level constants because they are looked up once from the prototypes.
@@ -75,8 +75,11 @@ const cloneMain = (value) => {
75
75
  else if (value instanceof Map) return new Map([...value].map(([k, v]) => [cloneMain(k), cloneMain(v)]));
76
76
  else if (value instanceof WeakSet || value instanceof WeakMap) throw new Error("WeakSet and WeakMap are not supported");
77
77
  else {
78
- const primitive = value.valueOf();
79
- if (primitive !== value) return cloneMain(primitive);
78
+ const valueOf = value.valueOf;
79
+ if (typeof valueOf === "function") {
80
+ const primitive = Reflect.apply(valueOf, value, []);
81
+ if (primitive !== value) return cloneMain(primitive);
82
+ }
80
83
  return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, cloneMain(v)]).filter(([, v]) => v !== void 0));
81
84
  }
82
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"_plainCloneAny.mjs","names":[],"sources":["../../src/internal/_plainCloneAny.ts"],"sourcesContent":["import { Resolved } from \"@typia/interface\";\n\n/**\n * Clone an untyped value into plain data.\n *\n * Arrays, sets, maps, dates, regular expressions, typed arrays, buffers, blobs,\n * files, boxed primitives and plain objects are rebuilt. Functions become\n * undefined; object properties with undefined results are omitted, while\n * arrays, sets and maps retain them. Weak collections throw. Cycles are not\n * tracked, and ordinary objects may invoke their own valueOf or property\n * getters.\n *\n * @evidence contracts/common.md#principled-implementation The clone walks the value and rebuilds arrays, sets, maps, boxed primitives, dates, regular expressions, typed arrays, buffers, data views, blobs, files and plain objects, turns functions into undefined, omits object properties whose cloned values are undefined while retaining such array/set/map results, and throws for weak collections. Native recognition checks intrinsic prototype accessors with `Reflect.apply` rather than trusting a supplied string tag or own getter; native clones use those captured accessors for their internal data. The ordinary-object branch invokes valueOf and clones its replacement when different, otherwise rebuilding enumerable own entries. Cycles are not tracked, so a cyclic value does not terminate.\n * @evidence contracts/common.md#clear-and-simple-design One entry function over a recognition function, a native cloner and a buffer range copier; the accessor captures are module-level constants because they are looked up once from the prototypes.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts Recognition uses the intrinsic prototype accessors and no foreign method is replaced; native tags are checked through them and not by the forgeable string tag alone.\n * @evidence contracts/common.md#meaningful-documentation A comment states the cloned kinds, the object-member omission, retained container entries, observable valueOf/getters and the cycle limitation.\n */\nexport const _plainCloneAny = <T>(value: T): Resolved<T> =>\n cloneMain(value) as Resolved<T>;\n\nconst NOT_NATIVE = Symbol(\"not-native\");\nconst objectToString = Object.prototype.toString;\nconst getter = (prototype: object, key: PropertyKey): (() => unknown) =>\n Object.getOwnPropertyDescriptor(prototype, key)!.get!;\nconst read = <T>(accessor: () => unknown, value: object): T =>\n Reflect.apply(accessor, value, []) as T;\nconst tryRead = <T>(\n accessor: (() => unknown) | undefined,\n value: object,\n): { success: true; value: T } | { success: false } => {\n if (accessor === undefined) return { success: false };\n try {\n return { success: true, value: read<T>(accessor, value) };\n } catch {\n return { success: false };\n }\n};\n\nconst arrayBufferByteLength = getter(ArrayBuffer.prototype, \"byteLength\");\nconst sharedArrayBufferByteLength =\n typeof SharedArrayBuffer === \"undefined\"\n ? undefined\n : getter(SharedArrayBuffer.prototype, \"byteLength\");\nconst dataViewBuffer = getter(DataView.prototype, \"buffer\");\nconst dataViewByteLength = getter(DataView.prototype, \"byteLength\");\nconst dataViewByteOffset = getter(DataView.prototype, \"byteOffset\");\nconst typedArrayName = getter(\n Object.getPrototypeOf(Uint8Array.prototype),\n Symbol.toStringTag,\n);\nconst blobSize =\n typeof Blob === \"undefined\" ? undefined : getter(Blob.prototype, \"size\");\nconst blobType =\n typeof Blob === \"undefined\" ? undefined : getter(Blob.prototype, \"type\");\nconst fileName =\n typeof File === \"undefined\" ? undefined : getter(File.prototype, \"name\");\nconst fileLastModified =\n typeof File === \"undefined\"\n ? undefined\n : getter(File.prototype, \"lastModified\");\nconst regexpSource = getter(RegExp.prototype, \"source\");\nconst regexpFlags = getter(RegExp.prototype, \"flags\");\n\nconst nativeTag = (value: object): string | undefined => {\n let tagged: boolean;\n try {\n tagged = Symbol.toStringTag in value;\n } catch {\n return undefined;\n }\n if (!tagged)\n try {\n return objectToString.call(value);\n } catch {\n return undefined;\n }\n\n const date = tryRead<number>(Date.prototype.getTime, value);\n if (date.success) return \"[object Date]\";\n const typed = tryRead<string>(typedArrayName, value);\n if (typed.success && typed.value !== undefined)\n return `[object ${typed.value}]`;\n if (tryRead<number>(arrayBufferByteLength, value).success)\n return \"[object ArrayBuffer]\";\n if (tryRead<number>(sharedArrayBufferByteLength, value).success)\n return \"[object SharedArrayBuffer]\";\n if (tryRead<ArrayBufferLike>(dataViewBuffer, value).success)\n return \"[object DataView]\";\n if (tryRead<string>(fileName, value).success) return \"[object File]\";\n if (tryRead<number>(blobSize, value).success) return \"[object Blob]\";\n if (tryRead<string>(regexpSource, value).success) return \"[object RegExp]\";\n return undefined;\n};\n\nconst cloneMain = (value: any): any => {\n if (value === undefined) return undefined;\n else if (typeof value === \"object\")\n if (value === null) return null;\n else if (Array.isArray(value)) return value.map(cloneMain);\n else {\n const native: any | typeof NOT_NATIVE = cloneNative(value);\n if (native !== NOT_NATIVE) return native;\n else if (value instanceof Set) return new Set([...value].map(cloneMain));\n else if (value instanceof Map)\n return new Map(\n [...value].map(([k, v]) => [cloneMain(k), cloneMain(v)]),\n );\n else if (value instanceof WeakSet || value instanceof WeakMap)\n throw new Error(\"WeakSet and WeakMap are not supported\");\n else {\n const primitive: unknown = value.valueOf();\n if (primitive !== value) return cloneMain(primitive);\n return Object.fromEntries(\n Object.entries(value)\n .map(([k, v]) => [k, cloneMain(v)])\n .filter(([, v]) => v !== undefined),\n );\n }\n }\n else if (typeof value === \"function\") return undefined;\n return value;\n};\n\nconst cloneNative = (value: object): any | typeof NOT_NATIVE => {\n const tag: string | undefined = nativeTag(value);\n switch (tag) {\n case \"[object Date]\": {\n const time = tryRead<number>(Date.prototype.getTime, value);\n return time.success ? new Date(time.value) : NOT_NATIVE;\n }\n case \"[object Uint8Array]\":\n return new Uint8Array(value as ArrayLike<number>);\n case \"[object Uint8ClampedArray]\":\n return new Uint8ClampedArray(value as ArrayLike<number>);\n case \"[object Uint16Array]\":\n return new Uint16Array(value as ArrayLike<number>);\n case \"[object Uint32Array]\":\n return new Uint32Array(value as ArrayLike<number>);\n case \"[object BigUint64Array]\":\n return new BigUint64Array(value as ArrayLike<bigint>);\n case \"[object Int8Array]\":\n return new Int8Array(value as ArrayLike<number>);\n case \"[object Int16Array]\":\n return new Int16Array(value as ArrayLike<number>);\n case \"[object Int32Array]\":\n return new Int32Array(value as ArrayLike<number>);\n case \"[object BigInt64Array]\":\n return new BigInt64Array(value as ArrayLike<bigint>);\n case \"[object Float32Array]\":\n return new Float32Array(value as ArrayLike<number>);\n case \"[object Float64Array]\":\n return new Float64Array(value as ArrayLike<number>);\n case \"[object ArrayBuffer]\": {\n const byteLength = tryRead<number>(arrayBufferByteLength, value);\n return byteLength.success\n ? cloneBufferRange(value as ArrayBuffer, 0, byteLength.value, false)\n : NOT_NATIVE;\n }\n case \"[object SharedArrayBuffer]\": {\n const byteLength = tryRead<number>(sharedArrayBufferByteLength, value);\n return byteLength.success\n ? cloneBufferRange(\n value as SharedArrayBuffer,\n 0,\n byteLength.value,\n true,\n )\n : NOT_NATIVE;\n }\n case \"[object DataView]\": {\n const buffer = tryRead<ArrayBufferLike>(dataViewBuffer, value);\n if (!buffer.success) return NOT_NATIVE;\n const byteOffset: number = read(dataViewByteOffset, value);\n const byteLength: number = read(dataViewByteLength, value);\n return new DataView(\n cloneBufferRange(buffer.value, byteOffset, byteLength),\n );\n }\n case \"[object File]\": {\n const size = tryRead<number>(blobSize, value);\n if (\n typeof File === \"undefined\" ||\n !size.success ||\n blobType === undefined ||\n fileName === undefined ||\n fileLastModified === undefined\n )\n return NOT_NATIVE;\n return new File([value as Blob], read<string>(fileName, value), {\n type: read<string>(blobType, value),\n lastModified: read<number>(fileLastModified, value),\n });\n }\n case \"[object Blob]\": {\n const size = tryRead<number>(blobSize, value);\n if (\n typeof Blob === \"undefined\" ||\n !size.success ||\n blobType === undefined\n )\n return NOT_NATIVE;\n return new Blob([value as Blob], {\n type: read<string>(blobType, value),\n });\n }\n case \"[object RegExp]\": {\n const source = tryRead<string>(regexpSource, value);\n return source.success\n ? new RegExp(source.value, read<string>(regexpFlags, value))\n : NOT_NATIVE;\n }\n default:\n return NOT_NATIVE;\n }\n};\n\nconst cloneBufferRange = (\n input: ArrayBufferLike,\n byteOffset: number,\n byteLength: number,\n shared?: boolean,\n): ArrayBuffer | SharedArrayBuffer => {\n if (shared === undefined)\n shared = tryRead<number>(sharedArrayBufferByteLength, input).success;\n let output: ArrayBuffer | SharedArrayBuffer;\n if (shared) {\n if (typeof SharedArrayBuffer === \"undefined\")\n throw new TypeError(\"SharedArrayBuffer is not available\");\n output = new SharedArrayBuffer(byteLength);\n } else {\n read<number>(arrayBufferByteLength, input);\n output = new ArrayBuffer(byteLength);\n }\n new Uint8Array(output).set(new Uint8Array(input, byteOffset, byteLength));\n return output;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAa,kBAAqB,UAChC,UAAU,KAAK;AAEjB,MAAM,aAAa,OAAO,YAAY;AACtC,MAAM,iBAAiB,OAAO,UAAU;AACxC,MAAM,UAAU,WAAmB,QACjC,OAAO,yBAAyB,WAAW,GAAG,CAAC,CAAE;AACnD,MAAM,QAAW,UAAyB,UACxC,QAAQ,MAAM,UAAU,OAAO,CAAC,CAAC;AACnC,MAAM,WACJ,UACA,UACqD;CACrD,IAAI,aAAa,KAAA,GAAW,OAAO,EAAE,SAAS,MAAM;CACpD,IAAI;EACF,OAAO;GAAE,SAAS;GAAM,OAAO,KAAQ,UAAU,KAAK;EAAE;CAC1D,QAAQ;EACN,OAAO,EAAE,SAAS,MAAM;CAC1B;AACF;AAEA,MAAM,wBAAwB,OAAO,YAAY,WAAW,YAAY;AACxE,MAAM,8BACJ,OAAO,sBAAsB,cACzB,KAAA,IACA,OAAO,kBAAkB,WAAW,YAAY;AACtD,MAAM,iBAAiB,OAAO,SAAS,WAAW,QAAQ;AAC1D,MAAM,qBAAqB,OAAO,SAAS,WAAW,YAAY;AAClE,MAAM,qBAAqB,OAAO,SAAS,WAAW,YAAY;AAClE,MAAM,iBAAiB,OACrB,OAAO,eAAe,WAAW,SAAS,GAC1C,OAAO,WACT;AACA,MAAM,WACJ,OAAO,SAAS,cAAc,K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OAAO,OAAO,OAAO,KAAa,aAAa,KAAK,CAAC,IACzD;EACN;EACA,SACE,OAAO;CACX;AACF;AAEA,MAAM,oBACJ,OACA,YACA,YACA,WACoC;CACpC,IAAI,WAAW,KAAA,GACb,SAAS,QAAgB,6BAA6B,KAAK,CAAC,CAAC;CAC/D,IAAI;CACJ,IAAI,QAAQ;EACV,IAAI,OAAO,sBAAsB,aAC/B,MAAM,IAAI,UAAU,oCAAoC;EAC1D,SAAS,IAAI,kBAAkB,UAAU;CAC3C,OAAO;EACL,KAAa,uBAAuB,KAAK;EACzC,SAAS,IAAI,YAAY,UAAU;CACrC;CACA,IAAI,WAAW,MAAM,CAAC,CAAC,IAAI,IAAI,WAAW,OAAO,YAAY,UAAU,CAAC;CACxE,OAAO;AACT"}
1
+ {"version":3,"file":"_plainCloneAny.mjs","names":[],"sources":["../../src/internal/_plainCloneAny.ts"],"sourcesContent":["import { Resolved } from \"@typia/interface\";\n\n/**\n * Clone an untyped value into plain data.\n *\n * Arrays, sets, maps, dates, regular expressions, typed arrays, buffers, blobs,\n * files, boxed primitives and plain objects are rebuilt. Functions become\n * undefined; object properties with undefined results are omitted, while\n * arrays, sets and maps retain them. Weak collections throw. Cycles are not\n * tracked, and ordinary objects may invoke a callable valueOf or property\n * getters. A missing or non-callable valueOf is ordinary data.\n *\n * @evidence contracts/common.md#principled-implementation The clone walks the value and rebuilds arrays, sets, maps, boxed primitives, dates, regular expressions, typed arrays, buffers, data views, blobs, files and plain objects, turns functions into undefined, omits object properties whose cloned values are undefined while retaining such array/set/map results, and throws for weak collections. Native recognition checks intrinsic prototype accessors with `Reflect.apply` rather than trusting a supplied string tag or own getter; native clones use those captured accessors for their internal data. The ordinary-object branch invokes valueOf and clones its replacement when different, otherwise rebuilding enumerable own entries. Cycles are not tracked, so a cyclic value does not terminate.\n * @evidence contracts/common.md#clear-and-simple-design One entry function over a recognition function, a native cloner and a buffer range copier; the accessor captures are module-level constants because they are looked up once from the prototypes.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts Recognition uses the intrinsic prototype accessors and no foreign method is replaced; native tags are checked through them and not by the forgeable string tag alone.\n * @evidence contracts/common.md#meaningful-documentation A comment states the cloned kinds, the object-member omission, retained container entries, observable valueOf/getters and the cycle limitation.\n */\nexport const _plainCloneAny = <T>(value: T): Resolved<T> =>\n cloneMain(value) as Resolved<T>;\n\nconst NOT_NATIVE = Symbol(\"not-native\");\nconst objectToString = Object.prototype.toString;\nconst getter = (prototype: object, key: PropertyKey): (() => unknown) =>\n Object.getOwnPropertyDescriptor(prototype, key)!.get!;\nconst read = <T>(accessor: () => unknown, value: object): T =>\n Reflect.apply(accessor, value, []) as T;\nconst tryRead = <T>(\n accessor: (() => unknown) | undefined,\n value: object,\n): { success: true; value: T } | { success: false } => {\n if (accessor === undefined) return { success: false };\n try {\n return { success: true, value: read<T>(accessor, value) };\n } catch {\n return { success: false };\n }\n};\n\nconst arrayBufferByteLength = getter(ArrayBuffer.prototype, \"byteLength\");\nconst sharedArrayBufferByteLength =\n typeof SharedArrayBuffer === \"undefined\"\n ? undefined\n : getter(SharedArrayBuffer.prototype, \"byteLength\");\nconst dataViewBuffer = getter(DataView.prototype, \"buffer\");\nconst dataViewByteLength = getter(DataView.prototype, \"byteLength\");\nconst dataViewByteOffset = getter(DataView.prototype, \"byteOffset\");\nconst typedArrayName = getter(\n Object.getPrototypeOf(Uint8Array.prototype),\n Symbol.toStringTag,\n);\nconst blobSize =\n typeof Blob === \"undefined\" ? undefined : getter(Blob.prototype, \"size\");\nconst blobType =\n typeof Blob === \"undefined\" ? undefined : getter(Blob.prototype, \"type\");\nconst fileName =\n typeof File === \"undefined\" ? undefined : getter(File.prototype, \"name\");\nconst fileLastModified =\n typeof File === \"undefined\"\n ? undefined\n : getter(File.prototype, \"lastModified\");\nconst regexpSource = getter(RegExp.prototype, \"source\");\nconst regexpFlags = getter(RegExp.prototype, \"flags\");\n\nconst nativeTag = (value: object): string | undefined => {\n let tagged: boolean;\n try {\n tagged = Symbol.toStringTag in value;\n } catch {\n return undefined;\n }\n if (!tagged)\n try {\n return objectToString.call(value);\n } catch {\n return undefined;\n }\n\n const date = tryRead<number>(Date.prototype.getTime, value);\n if (date.success) return \"[object Date]\";\n const typed = tryRead<string>(typedArrayName, value);\n if (typed.success && typed.value !== undefined)\n return `[object ${typed.value}]`;\n if (tryRead<number>(arrayBufferByteLength, value).success)\n return \"[object ArrayBuffer]\";\n if (tryRead<number>(sharedArrayBufferByteLength, value).success)\n return \"[object SharedArrayBuffer]\";\n if (tryRead<ArrayBufferLike>(dataViewBuffer, value).success)\n return \"[object DataView]\";\n if (tryRead<string>(fileName, value).success) return \"[object File]\";\n if (tryRead<number>(blobSize, value).success) return \"[object Blob]\";\n if (tryRead<string>(regexpSource, value).success) return \"[object RegExp]\";\n return undefined;\n};\n\nconst cloneMain = (value: any): any => {\n if (value === undefined) return undefined;\n else if (typeof value === \"object\")\n if (value === null) return null;\n else if (Array.isArray(value)) return value.map(cloneMain);\n else {\n const native: any | typeof NOT_NATIVE = cloneNative(value);\n if (native !== NOT_NATIVE) return native;\n else if (value instanceof Set) return new Set([...value].map(cloneMain));\n else if (value instanceof Map)\n return new Map(\n [...value].map(([k, v]) => [cloneMain(k), cloneMain(v)]),\n );\n else if (value instanceof WeakSet || value instanceof WeakMap)\n throw new Error(\"WeakSet and WeakMap are not supported\");\n else {\n const valueOf: unknown = value.valueOf;\n if (typeof valueOf === \"function\") {\n const primitive: unknown = Reflect.apply(valueOf, value, []);\n if (primitive !== value) return cloneMain(primitive);\n }\n return Object.fromEntries(\n Object.entries(value)\n .map(([k, v]) => [k, cloneMain(v)])\n .filter(([, v]) => v !== undefined),\n );\n }\n }\n else if (typeof value === \"function\") return undefined;\n return value;\n};\n\nconst cloneNative = (value: object): any | typeof NOT_NATIVE => {\n const tag: string | undefined = nativeTag(value);\n switch (tag) {\n case \"[object Date]\": {\n const time = tryRead<number>(Date.prototype.getTime, value);\n return time.success ? new Date(time.value) : NOT_NATIVE;\n }\n case \"[object Uint8Array]\":\n return new Uint8Array(value as ArrayLike<number>);\n case \"[object Uint8ClampedArray]\":\n return new Uint8ClampedArray(value as ArrayLike<number>);\n case \"[object Uint16Array]\":\n return new Uint16Array(value as ArrayLike<number>);\n case \"[object Uint32Array]\":\n return new Uint32Array(value as ArrayLike<number>);\n case \"[object BigUint64Array]\":\n return new BigUint64Array(value as ArrayLike<bigint>);\n case \"[object Int8Array]\":\n return new Int8Array(value as ArrayLike<number>);\n case \"[object Int16Array]\":\n return new Int16Array(value as ArrayLike<number>);\n case \"[object Int32Array]\":\n return new Int32Array(value as ArrayLike<number>);\n case \"[object BigInt64Array]\":\n return new BigInt64Array(value as ArrayLike<bigint>);\n case \"[object Float32Array]\":\n return new Float32Array(value as ArrayLike<number>);\n case \"[object Float64Array]\":\n return new Float64Array(value as ArrayLike<number>);\n case \"[object ArrayBuffer]\": {\n const byteLength = tryRead<number>(arrayBufferByteLength, value);\n return byteLength.success\n ? cloneBufferRange(value as ArrayBuffer, 0, byteLength.value, false)\n : NOT_NATIVE;\n }\n case \"[object SharedArrayBuffer]\": {\n const byteLength = tryRead<number>(sharedArrayBufferByteLength, value);\n return byteLength.success\n ? cloneBufferRange(\n value as SharedArrayBuffer,\n 0,\n byteLength.value,\n true,\n )\n : NOT_NATIVE;\n }\n case \"[object DataView]\": {\n const buffer = tryRead<ArrayBufferLike>(dataViewBuffer, value);\n if (!buffer.success) return NOT_NATIVE;\n const byteOffset: number = read(dataViewByteOffset, value);\n const byteLength: number = read(dataViewByteLength, value);\n return new DataView(\n cloneBufferRange(buffer.value, byteOffset, byteLength),\n );\n }\n case \"[object File]\": {\n const size = tryRead<number>(blobSize, value);\n if (\n typeof File === \"undefined\" ||\n !size.success ||\n blobType === undefined ||\n fileName === undefined ||\n fileLastModified === undefined\n )\n return NOT_NATIVE;\n return new File([value as Blob], read<string>(fileName, value), {\n type: read<string>(blobType, value),\n lastModified: read<number>(fileLastModified, value),\n });\n }\n case \"[object Blob]\": {\n const size = tryRead<number>(blobSize, value);\n if (\n typeof Blob === \"undefined\" ||\n !size.success ||\n blobType === undefined\n )\n return NOT_NATIVE;\n return new Blob([value as Blob], {\n type: read<string>(blobType, value),\n });\n }\n case \"[object RegExp]\": {\n const source = tryRead<string>(regexpSource, value);\n return source.success\n ? new RegExp(source.value, read<string>(regexpFlags, value))\n : NOT_NATIVE;\n }\n default:\n return NOT_NATIVE;\n }\n};\n\nconst cloneBufferRange = (\n input: ArrayBufferLike,\n byteOffset: number,\n byteLength: number,\n shared?: boolean,\n): ArrayBuffer | SharedArrayBuffer => {\n if (shared === undefined)\n shared = tryRead<number>(sharedArrayBufferByteLength, input).success;\n let output: ArrayBuffer | SharedArrayBuffer;\n if (shared) {\n if (typeof SharedArrayBuffer === \"undefined\")\n throw new TypeError(\"SharedArrayBuffer is not available\");\n output = new SharedArrayBuffer(byteLength);\n } else {\n read<number>(arrayBufferByteLength, input);\n output = new ArrayBuffer(byteLength);\n }\n new Uint8Array(output).set(new Uint8Array(input, byteOffset, byteLength));\n return output;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAa,kBAAqB,UAChC,UAAU,KAAK;AAEjB,MAAM,aAAa,OAAO,YAAY;AACtC,MAAM,iBAAiB,OAAO,UAAU;AACxC,MAAM,UAAU,WAAmB,QACjC,OAAO,yBAAyB,WAAW,GAAG,CAAC,CAAE;AACnD,MAAM,QAAW,UAAyB,UACxC,QAAQ,MAAM,UAAU,OAAO,CAAC,CAAC;AACnC,MAAM,WACJ,UACA,UACqD;CACrD,IAAI,aAAa,KAAA,GAAW,OAAO,EAAE,SAAS,MAAM;CACpD,IAAI;EACF,OAAO;GAAE,SAAS;GAAM,OAAO,KAAQ,UAAU,KAAK;EAAE;CAC1D,QAAQ;EACN,OAAO,EAAE,SAAS,MAAM;CAC1B;AACF;AAEA,MAAM,wBAAwB,OAAO,YAAY,WAAW,YAAY;AACxE,MAAM,8BACJ,OAAO,sBAAsB,cACzB,KAAA,IACA,OAAO,k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,cAAc,KAAa,kBAAkB,KAAK;GACpD,CAAC;EACH;EACA,KAAK,iBAAiB;GACpB,MAAM,OAAO,QAAgB,UAAU,KAAK;GAC5C,IACE,OAAO,SAAS,eAChB,CAAC,KAAK,WACN,aAAa,KAAA,GAEb,OAAO;GACT,OAAO,IAAI,KAAK,CAAC,KAAa,GAAG,EAC/B,MAAM,KAAa,UAAU,KAAK,EACpC,CAAC;EACH;EACA,KAAK,mBAAmB;GACtB,MAAM,SAAS,QAAgB,cAAc,KAAK;GAClD,OAAO,OAAO,UACV,IAAI,OAAO,OAAO,OAAO,KAAa,aAAa,KAAK,CAAC,IACzD;EACN;EACA,SACE,OAAO;CACX;AACF;AAEA,MAAM,oBACJ,OACA,YACA,YACA,WACoC;CACpC,IAAI,WAAW,KAAA,GACb,SAAS,QAAgB,6BAA6B,KAAK,CAAC,CAAC;CAC/D,IAAI;CACJ,IAAI,QAAQ;EACV,IAAI,OAAO,sBAAsB,aAC/B,MAAM,IAAI,UAAU,oCAAoC;EAC1D,SAAS,IAAI,kBAAkB,UAAU;CAC3C,OAAO;EACL,KAAa,uBAAuB,KAAK;EACzC,SAAS,IAAI,YAAY,UAAU;CACrC;CACA,IAAI,WAAW,MAAM,CAAC,CAAC,IAAI,IAAI,WAAW,OAAO,YAAY,UAAU,CAAC;CACxE,OAAO;AACT"}
@@ -10,7 +10,9 @@ import type { ITtscPlugin, ITtscPluginFactoryContext } from "ttsc";
10
10
  * resolution, so an empty hostInputHashes declaration permits safe descriptor
11
11
  * replay. The native build host supplies generation-owned input observations
12
12
  * and compiler-owned output provenance for ttsc's checked runtime reuse
13
- * protocol.
13
+ * protocol. Its only variable reads outside ttsc's own namespace go through the
14
+ * program's recorded `Env`, so it declares `environmentInputs` and ttsc keys
15
+ * its outputs by the variables it read instead of the whole environment.
14
16
  *
15
17
  * @param context Plugin factory context of ttsc
16
18
  *
package/lib/transform.js CHANGED
@@ -17,7 +17,9 @@ const node_path_1 = __importDefault(require("node:path"));
17
17
  * resolution, so an empty hostInputHashes declaration permits safe descriptor
18
18
  * replay. The native build host supplies generation-owned input observations
19
19
  * and compiler-owned output provenance for ttsc's checked runtime reuse
20
- * protocol.
20
+ * protocol. Its only variable reads outside ttsc's own namespace go through the
21
+ * program's recorded `Env`, so it declares `environmentInputs` and ttsc keys
22
+ * its outputs by the variables it read instead of the whole environment.
21
23
  *
22
24
  * @param context Plugin factory context of ttsc
23
25
  *
@@ -41,6 +43,7 @@ function createTtscPlugin(context) {
41
43
  capabilities: {
42
44
  emitObservations: true,
43
45
  emitProvenance: true,
46
+ environmentInputs: true,
44
47
  },
45
48
  };
46
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","sources":["../src/transform.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA4C;AAC5C,0DAA6B;AAG7B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,0BACE,OAAkC;IAElC,oEAAoE;IACpE,wEAAwE;IACxE,2EAA2E;IAC3E,MAAM,WAAW,GAAG,IAAA,2BAAa,EAC/B,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAC/C,CAAC;IACF,MAAM,IAAI,GAAW,mBAAI,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC7E,OAAO;QACL,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,mBAAI,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,CAAC;QACzD,eAAe,EAAE,EAAE;QACnB,YAAY,EAAE;YACZ,gBAAgB,EAAE,IAAI;YACtB,cAAc,EAAE,IAAI;SACrB;KACF,CAAC;AACJ,CAAC;kBAEc,gBAAgB"}
1
+ {"version":3,"file":"transform.js","sources":["../src/transform.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA4C;AAC5C,0DAA6B;AAG7B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,0BACE,OAAkC;IAElC,oEAAoE;IACpE,wEAAwE;IACxE,2EAA2E;IAC3E,MAAM,WAAW,GAAG,IAAA,2BAAa,EAC/B,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAC/C,CAAC;IACF,MAAM,IAAI,GAAW,mBAAI,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC7E,OAAO;QACL,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,mBAAI,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,CAAC;QACzD,eAAe,EAAE,EAAE;QACnB,YAAY,EAAE;YACZ,gBAAgB,EAAE,IAAI;YACtB,cAAc,EAAE,IAAI;YACpB,iBAAiB,EAAE,IAAI;SACxB;KACF,CAAC;AACJ,CAAC;kBAEc,gBAAgB"}
package/lib/transform.mjs CHANGED
@@ -12,7 +12,9 @@ import path from "node:path";
12
12
  * resolution, so an empty hostInputHashes declaration permits safe descriptor
13
13
  * replay. The native build host supplies generation-owned input observations
14
14
  * and compiler-owned output provenance for ttsc's checked runtime reuse
15
- * protocol.
15
+ * protocol. Its only variable reads outside ttsc's own namespace go through the
16
+ * program's recorded `Env`, so it declares `environmentInputs` and ttsc keys
17
+ * its outputs by the variables it read instead of the whole environment.
16
18
  *
17
19
  * @param context Plugin factory context of ttsc
18
20
  *
@@ -32,7 +34,8 @@ function createTtscPlugin(context) {
32
34
  hostInputHashes: {},
33
35
  capabilities: {
34
36
  emitObservations: true,
35
- emitProvenance: true
37
+ emitProvenance: true,
38
+ environmentInputs: true
36
39
  }
37
40
  };
38
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transform.mjs","names":[],"sources":["../src/transform.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport type { ITtscPlugin, ITtscPluginFactoryContext } from \"ttsc\";\n\n/**\n * Describe typia's native transform to ttsc.\n *\n * Ttsc loads this file as an ES module, where `require` is unavailable, so a\n * resolver is anchored on the consuming project to find typia's own package\n * root. The returned descriptor names the plugin and the Go command under\n * `native/cmd/ttsc-typia`; the transform itself is not written in TypeScript.\n * No file is read outside the module graph. Ttsc records the package\n * resolution, so an empty hostInputHashes declaration permits safe descriptor\n * replay. The native build host supplies generation-owned input observations\n * and compiler-owned output provenance for ttsc's checked runtime reuse\n * protocol.\n *\n * @param context Plugin factory context of ttsc\n *\n * @returns Plugin descriptor\n *\n * @evidence contracts/common.md#principled-implementation The ttsc loader runs this file as an ES module where `require` is absent, so the function builds a CommonJS resolver anchored at the consuming project and resolves typia's own `package.json`, whose directory holds the native sources. No external file is read; ttsc records that module lookup and invalidates descriptor replay when its module graph or factory inputs change. The descriptor names the plugin and Go command under `native/cmd/ttsc-typia`.\n * @evidence contracts/common.md#clear-and-simple-design One function returns the plugin name, Go source, supported native protocols and external-input declaration; the default export repeats the same function for loaders that read it.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The package root comes from the installed typia through the supported resolver and not from path substrings, so it works for npm consumers and workspaces alike; the transform itself stays in Go.\n * @evidence contracts/common.md#meaningful-documentation A comment explains the purpose, the ESM resolution reason and the descriptor.\n */\nexport function createTtscPlugin(\n context: ITtscPluginFactoryContext,\n): ITtscPlugin {\n // ttsc loads this descriptor as ESM, where the ambient `require` is\n // unavailable; anchor a CJS resolver on the consuming project to locate\n // typia's own package root (not the project root, which has no `native/`).\n const requireFrom = createRequire(\n path.join(context.projectRoot, \"package.json\"),\n );\n const root: string = path.dirname(requireFrom.resolve(\"typia/package.json\"));\n return {\n name: \"typia\",\n source: path.resolve(root, \"native\", \"cmd\", \"ttsc-typia\"),\n hostInputHashes: {},\n capabilities: {\n emitObservations: true,\n emitProvenance: true,\n },\n };\n}\n\nexport default createTtscPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,iBACd,SACa;CAIb,MAAM,cAAc,cAClB,KAAK,KAAK,QAAQ,aAAa,cAAc,CAC/C;CACA,MAAM,OAAe,KAAK,QAAQ,YAAY,QAAQ,oBAAoB,CAAC;CAC3E,OAAO;EACL,MAAM;EACN,QAAQ,KAAK,QAAQ,MAAM,UAAU,OAAO,YAAY;EACxD,iBAAiB,CAAC;EAClB,cAAc;GACZ,kBAAkB;GAClB,gBAAgB;EAClB;CACF;AACF"}
1
+ {"version":3,"file":"transform.mjs","names":[],"sources":["../src/transform.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport type { ITtscPlugin, ITtscPluginFactoryContext } from \"ttsc\";\n\n/**\n * Describe typia's native transform to ttsc.\n *\n * Ttsc loads this file as an ES module, where `require` is unavailable, so a\n * resolver is anchored on the consuming project to find typia's own package\n * root. The returned descriptor names the plugin and the Go command under\n * `native/cmd/ttsc-typia`; the transform itself is not written in TypeScript.\n * No file is read outside the module graph. Ttsc records the package\n * resolution, so an empty hostInputHashes declaration permits safe descriptor\n * replay. The native build host supplies generation-owned input observations\n * and compiler-owned output provenance for ttsc's checked runtime reuse\n * protocol. Its only variable reads outside ttsc's own namespace go through the\n * program's recorded `Env`, so it declares `environmentInputs` and ttsc keys\n * its outputs by the variables it read instead of the whole environment.\n *\n * @param context Plugin factory context of ttsc\n *\n * @returns Plugin descriptor\n *\n * @evidence contracts/common.md#principled-implementation The ttsc loader runs this file as an ES module where `require` is absent, so the function builds a CommonJS resolver anchored at the consuming project and resolves typia's own `package.json`, whose directory holds the native sources. No external file is read; ttsc records that module lookup and invalidates descriptor replay when its module graph or factory inputs change. The descriptor names the plugin and Go command under `native/cmd/ttsc-typia`.\n * @evidence contracts/common.md#clear-and-simple-design One function returns the plugin name, Go source, supported native protocols and external-input declaration; the default export repeats the same function for loaders that read it.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The package root comes from the installed typia through the supported resolver and not from path substrings, so it works for npm consumers and workspaces alike; the transform itself stays in Go.\n * @evidence contracts/common.md#meaningful-documentation A comment explains the purpose, the ESM resolution reason and the descriptor.\n */\nexport function createTtscPlugin(\n context: ITtscPluginFactoryContext,\n): ITtscPlugin {\n // ttsc loads this descriptor as ESM, where the ambient `require` is\n // unavailable; anchor a CJS resolver on the consuming project to locate\n // typia's own package root (not the project root, which has no `native/`).\n const requireFrom = createRequire(\n path.join(context.projectRoot, \"package.json\"),\n );\n const root: string = path.dirname(requireFrom.resolve(\"typia/package.json\"));\n return {\n name: \"typia\",\n source: path.resolve(root, \"native\", \"cmd\", \"ttsc-typia\"),\n hostInputHashes: {},\n capabilities: {\n emitObservations: true,\n emitProvenance: true,\n environmentInputs: true,\n },\n };\n}\n\nexport default createTtscPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,iBACd,SACa;CAIb,MAAM,cAAc,cAClB,KAAK,KAAK,QAAQ,aAAa,cAAc,CAC/C;CACA,MAAM,OAAe,KAAK,QAAQ,YAAY,QAAQ,oBAAoB,CAAC;CAC3E,OAAO;EACL,MAAM;EACN,QAAQ,KAAK,QAAQ,MAAM,UAAU,OAAO,YAAY;EACxD,iBAAiB,CAAC;EAClB,cAAc;GACZ,kBAAkB;GAClB,gBAAgB;GAChB,mBAAmB;EACrB;CACF;AACF"}
@@ -0,0 +1,81 @@
1
+ package main
2
+
3
+ import (
4
+ "os"
5
+ "path/filepath"
6
+ "strings"
7
+ "testing"
8
+ )
9
+
10
+ // TestNotationEmptyObjectTransform verifies notation emission for an object type without properties.
11
+ //
12
+ // An arrow function whose body starts with `{` is a block, so a notation helper emitted as `input => {}` returns undefined instead of an empty object (#2536).
13
+ //
14
+ // 1. The fixture converts `{}` and `object` at the root and as a property through camel, snake and pascal notations, beside a sibling property that must still be renamed.
15
+ // 2. The output emits every empty notation helper as a parenthesized object literal, never as an empty block body, and keeps the renamed sibling property.
16
+ //
17
+ // @evidence contracts/testing.md#behavioral-verification The output emits every empty notation helper as a parenthesized object literal, never as an empty block body, and keeps the renamed sibling property.
18
+ // @evidence contracts/testing.md#independent-expectations An arrow function whose body starts with `{` is a block, so a notation helper emitted as `input => {}` returns undefined instead of an empty object (#2536).
19
+ // @evidence contracts/testing.md#distinguishing-cases The fixture converts `{}` and `object` at the root and as a property through camel, snake and pascal notations, beside a sibling property that must still be renamed.
20
+ // @evidence contracts/testing.md#execution-ownership The native Go runner discovers TestNotationEmptyObjectTransform as a unit test. The fixture and captured Go operation execute in process; helper assertions retain the same source inputs and failure identity without launching a compiler or JavaScript subprocess.
21
+ func TestNotationEmptyObjectTransform(t *testing.T) {
22
+ project := notationEmptyObjectProject(t)
23
+ out, errText, code := ttscTypiaTestCapture(func() int {
24
+ return runTransform([]string{
25
+ "--cwd", project,
26
+ "--tsconfig", "tsconfig.json",
27
+ "--file", "src/main.ts",
28
+ "--output", "js",
29
+ })
30
+ })
31
+ if code != 0 {
32
+ t.Fatalf("empty object notation transform failed: code=%d stderr=\n%s", code, errText)
33
+ }
34
+ if strings.Contains(out, "=> {}") {
35
+ t.Fatalf("empty object notation must not emit an empty arrow block body:\n%s", out)
36
+ }
37
+ if !strings.Contains(out, "=> ({})") {
38
+ t.Fatalf("empty object notation should emit a parenthesized empty object literal:\n%s", out)
39
+ }
40
+ if !strings.Contains(out, "second_value") {
41
+ t.Fatalf("sibling property of an empty object should still be renamed:\n%s", out)
42
+ }
43
+ }
44
+
45
+ func notationEmptyObjectProject(t *testing.T) string {
46
+ t.Helper()
47
+ dir := ttscTypiaTestFixtureDirectory(t, "notation-empty-object-")
48
+ src := filepath.Join(dir, "src")
49
+ if err := os.MkdirAll(src, 0o755); err != nil {
50
+ t.Fatalf("mkdir fixture src: %v", err)
51
+ }
52
+ if err := os.WriteFile(filepath.Join(dir, "tsconfig.json"), []byte(notationEmptyObjectTSConfig), 0o644); err != nil {
53
+ t.Fatalf("write tsconfig: %v", err)
54
+ }
55
+ if err := os.WriteFile(filepath.Join(src, "main.ts"), []byte(notationEmptyObjectSource), 0o644); err != nil {
56
+ t.Fatalf("write source: %v", err)
57
+ }
58
+ return dir
59
+ }
60
+
61
+ const notationEmptyObjectTSConfig = `{
62
+ "compilerOptions": {
63
+ "target": "ES2022",
64
+ "module": "commonjs",
65
+ "moduleResolution": "bundler",
66
+ "ignoreDeprecations": "6.0",
67
+ "types": ["*"],
68
+ "esModuleInterop": true,
69
+ "strict": true,
70
+ "skipLibCheck": true
71
+ },
72
+ "include": ["src"]
73
+ }
74
+ `
75
+
76
+ const notationEmptyObjectSource = `import typia from "typia";
77
+
78
+ export const camelRoot = typia.notations.createCamel<{}>();
79
+ export const snakeProperty = typia.notations.createSnake<{ firstValue: {}; secondValue: number }>();
80
+ export const pascalObjectKeyword = typia.notations.createPascal<object>();
81
+ `
@@ -0,0 +1,84 @@
1
+ package main
2
+
3
+ import (
4
+ "os"
5
+ "path/filepath"
6
+ "strings"
7
+ "testing"
8
+ )
9
+
10
+ // TestPlainCloneEmptyObjectTransform verifies clone emission for an object type without properties.
11
+ //
12
+ // An arrow function whose body starts with `{` is a block, so a clone helper emitted as `input => {}` returns undefined instead of an empty object (#2536).
13
+ //
14
+ // 1. The fixture clones `{}` and `object` at the root, as a property, as a Map value and through isClone/assertClone, beside a sibling property that must still be copied.
15
+ // 2. The output emits every empty clone helper as a parenthesized object literal, never as an empty block body, and keeps the sibling property assignment.
16
+ //
17
+ // @evidence contracts/testing.md#behavioral-verification The output emits every empty clone helper as a parenthesized object literal, never as an empty block body, and keeps the sibling property assignment.
18
+ // @evidence contracts/testing.md#independent-expectations An arrow function whose body starts with `{` is a block, so a clone helper emitted as `input => {}` returns undefined instead of an empty object (#2536).
19
+ // @evidence contracts/testing.md#distinguishing-cases The fixture clones `{}` and `object` at the root, as a property, as a Map value and through isClone/assertClone, beside a sibling property that must still be copied.
20
+ // @evidence contracts/testing.md#execution-ownership The native Go runner discovers TestPlainCloneEmptyObjectTransform as a unit test. The fixture and captured Go operation execute in process; helper assertions retain the same source inputs and failure identity without launching a compiler or JavaScript subprocess.
21
+ func TestPlainCloneEmptyObjectTransform(t *testing.T) {
22
+ project := plainCloneEmptyObjectProject(t)
23
+ out, errText, code := ttscTypiaTestCapture(func() int {
24
+ return runTransform([]string{
25
+ "--cwd", project,
26
+ "--tsconfig", "tsconfig.json",
27
+ "--file", "src/main.ts",
28
+ "--output", "js",
29
+ })
30
+ })
31
+ if code != 0 {
32
+ t.Fatalf("empty object clone transform failed: code=%d stderr=\n%s", code, errText)
33
+ }
34
+ if strings.Contains(out, "=> {}") {
35
+ t.Fatalf("empty object clone must not emit an empty arrow block body:\n%s", out)
36
+ }
37
+ if !strings.Contains(out, "=> ({})") {
38
+ t.Fatalf("empty object clone should emit a parenthesized empty object literal:\n%s", out)
39
+ }
40
+ if !strings.Contains(out, "b: input.b") {
41
+ t.Fatalf("sibling property of an empty object should still be cloned:\n%s", out)
42
+ }
43
+ }
44
+
45
+ func plainCloneEmptyObjectProject(t *testing.T) string {
46
+ t.Helper()
47
+ dir := ttscTypiaTestFixtureDirectory(t, "plain-clone-empty-object-")
48
+ src := filepath.Join(dir, "src")
49
+ if err := os.MkdirAll(src, 0o755); err != nil {
50
+ t.Fatalf("mkdir fixture src: %v", err)
51
+ }
52
+ if err := os.WriteFile(filepath.Join(dir, "tsconfig.json"), []byte(plainCloneEmptyObjectTSConfig), 0o644); err != nil {
53
+ t.Fatalf("write tsconfig: %v", err)
54
+ }
55
+ if err := os.WriteFile(filepath.Join(src, "main.ts"), []byte(plainCloneEmptyObjectSource), 0o644); err != nil {
56
+ t.Fatalf("write source: %v", err)
57
+ }
58
+ return dir
59
+ }
60
+
61
+ const plainCloneEmptyObjectTSConfig = `{
62
+ "compilerOptions": {
63
+ "target": "ES2022",
64
+ "module": "commonjs",
65
+ "moduleResolution": "bundler",
66
+ "ignoreDeprecations": "6.0",
67
+ "types": ["*"],
68
+ "esModuleInterop": true,
69
+ "strict": true,
70
+ "skipLibCheck": true
71
+ },
72
+ "include": ["src"]
73
+ }
74
+ `
75
+
76
+ const plainCloneEmptyObjectSource = `import typia from "typia";
77
+
78
+ export const cloneRoot = typia.plain.createClone<{}>();
79
+ export const cloneObjectKeyword = typia.plain.createClone<object>();
80
+ export const cloneProperty = typia.plain.createClone<{ a: {}; b: number }>();
81
+ export const cloneMapValue = typia.plain.createClone<Map<string, {}>>();
82
+ export const isClone = typia.plain.createIsClone<{}>();
83
+ export const assertClone = typia.plain.createAssertClone<{ a: object }>();
84
+ `
@@ -41,7 +41,7 @@ func runTransform(args []string) int {
41
41
  cwdOverride := fs.String("cwd", "", "override the working directory")
42
42
  out := fs.String("out", "", "write single-file output to PATH instead of stdout")
43
43
  rewriteMode := fs.String("rewrite-mode", "typia", "native rewrite backend id")
44
- output := fs.String("output", defaultTransformOutput(), "single-file output kind: js or ts")
44
+ output := fs.String("output", "", "single-file output kind: js or ts (default: TYPIA_TTSC_TRANSFORM_OUTPUT, else ts)")
45
45
  pluginsJSON := fs.String("plugins-json", "", "ordered ttsc plugin payload")
46
46
  if err := fs.Parse(args); err != nil {
47
47
  return 2
@@ -50,7 +50,7 @@ func runTransform(args []string) int {
50
50
  fmt.Fprintf(stderr, "ttsc-typia transform: unknown --rewrite-mode value %q\n", *rewriteMode)
51
51
  return 2
52
52
  }
53
- if *output != "js" && *output != "ts" {
53
+ if *output != "" && *output != "js" && *output != "ts" {
54
54
  fmt.Fprintf(stderr, "ttsc-typia transform: unknown --output value %q\n", *output)
55
55
  return 2
56
56
  }
@@ -119,8 +119,12 @@ func runTransform(args []string) int {
119
119
  fmt.Fprintf(stderr, "ttsc-typia transform: source file is not in program: %s\n", absFile)
120
120
  return 2
121
121
  }
122
+ kind := *output
123
+ if kind == "" {
124
+ kind = defaultTransformOutput(prog)
125
+ }
122
126
  return runTransformSingle(cwd, *out, &transformDiags, func() (string, int) {
123
- if *output == "js" {
127
+ if kind == "js" {
124
128
  return transformSingleToJavaScript(prog, typiaTransform, target)
125
129
  }
126
130
  return transformFileToTypeScript(prog, typiaTransform, target), 0
@@ -377,8 +381,13 @@ func writeSingleOutput(text, outPath string) int {
377
381
  return 0
378
382
  }
379
383
 
380
- func defaultTransformOutput() string {
381
- if os.Getenv("TYPIA_TTSC_TRANSFORM_OUTPUT") == "js" {
384
+ // defaultTransformOutput is the single-file output kind when --output is not
385
+ // given: `TYPIA_TTSC_TRANSFORM_OUTPUT=js` selects JavaScript, anything else
386
+ // TypeScript. It is read through the program, which records the read as an
387
+ // input of this generation, so a host that reuses this output under another
388
+ // value sees the change; os.Getenv was recorded by nothing (samchon/ttsc#1852).
389
+ func defaultTransformOutput(prog *driver.Program) string {
390
+ if value, _ := prog.Env("TYPIA_TTSC_TRANSFORM_OUTPUT"); value == "js" {
382
391
  return "js"
383
392
  }
384
393
  return "ts"
@@ -0,0 +1,67 @@
1
+ package main
2
+
3
+ import (
4
+ "os"
5
+ "path/filepath"
6
+ "strings"
7
+ "testing"
8
+ )
9
+
10
+ // TestTransformOutputDefaultFollowsTheRecordedVariable verifies the single-file
11
+ // output kind defaults to TYPIA_TTSC_TRANSFORM_OUTPUT read through the loaded
12
+ // program, and that an explicit --output still wins.
13
+ //
14
+ // The default was read with os.Getenv while flags were parsed, before any
15
+ // program existed, so nothing recorded it and a host reusing output across
16
+ // launches could not tell a changed value (samchon/ttsc#1852). The program's
17
+ // Env records the read as an input of the generation.
18
+ //
19
+ // 1. Transform one annotated declaration with the variable set to js and no
20
+ // --output: the annotation is gone.
21
+ // 2. Keep the variable at js and pass --output ts: the annotation stays.
22
+ // 3. Unset the variable: the annotation stays.
23
+ //
24
+ // @evidence contracts/testing.md#behavioral-verification The real transform command runs over a real program; the printed declaration shows which output kind ran.
25
+ // @evidence contracts/testing.md#independent-expectations TypeScript output keeps the authored `: number` annotation and JavaScript output drops it, independently of typia's rewriting.
26
+ // @evidence contracts/testing.md#distinguishing-cases The variable set, unset, and overridden by an explicit flag separate the default from the flag.
27
+ // @evidence contracts/testing.md#execution-ownership The native Go runner owns the temporary fixture and the in-process transform; t.Setenv restores the variable.
28
+ func TestTransformOutputDefaultFollowsTheRecordedVariable(t *testing.T) {
29
+ dir := ttscTypiaTestFixtureDirectory(t, "transform-output-default-")
30
+ src := filepath.Join(dir, "src")
31
+ if err := os.MkdirAll(src, 0o755); err != nil {
32
+ t.Fatalf("mkdir fixture src: %v", err)
33
+ }
34
+ if err := os.WriteFile(filepath.Join(dir, "tsconfig.json"), []byte(atomicIntersectionSchemaTSConfig), 0o644); err != nil {
35
+ t.Fatalf("write tsconfig: %v", err)
36
+ }
37
+ if err := os.WriteFile(filepath.Join(src, "main.ts"), []byte("export const answer: number = 42;\n"), 0o644); err != nil {
38
+ t.Fatalf("write source: %v", err)
39
+ }
40
+ transform := func(extra ...string) string {
41
+ t.Helper()
42
+ out, errText, code := ttscTypiaTestCapture(func() int {
43
+ return runTransform(append([]string{
44
+ "--cwd", dir,
45
+ "--tsconfig", "tsconfig.json",
46
+ "--file", "src/main.ts",
47
+ }, extra...))
48
+ })
49
+ if code != 0 {
50
+ t.Fatalf("transform failed: code=%d stderr=\n%s", code, errText)
51
+ }
52
+ return out
53
+ }
54
+ annotated := func(out string) bool { return strings.Contains(out, "answer: number") }
55
+
56
+ t.Setenv("TYPIA_TTSC_TRANSFORM_OUTPUT", "js")
57
+ if out := transform(); annotated(out) {
58
+ t.Fatalf("the variable selects JavaScript output:\n%s", out)
59
+ }
60
+ if out := transform("--output", "ts"); !annotated(out) {
61
+ t.Fatalf("an explicit --output ts wins over the variable:\n%s", out)
62
+ }
63
+ os.Unsetenv("TYPIA_TTSC_TRANSFORM_OUTPUT")
64
+ if out := transform(); !annotated(out) {
65
+ t.Fatalf("without the variable the output is TypeScript:\n%s", out)
66
+ }
67
+ }
@@ -5,13 +5,15 @@ import (
5
5
  schemametadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
6
6
  )
7
7
 
8
+ const unsupportedSymbolValue = "unsupported type: symbol values are not supported"
9
+
8
10
  // Iterate_metadata fills a metadata schema from a type by trying the iterators in
9
11
  // a fixed order until one accepts it.
10
12
  //
11
13
  // Aliases, intersections, unions and escapes come first, then any, null and
12
14
  // undefined-like types, functions, constants, templates, atomics, tuples, arrays,
13
15
  // natives, maps, sets and finally objects. A type parameter is reported as an
14
- // error.
16
+ // error, as is a symbol value.
15
17
  //
16
18
  // @evidence contracts/common.md#principled-implementation The chain tries each iterator in a fixed order and stops at the first that accepts: alias, intersection, union and escape first so wrappers are expanded before their contents, then special types, functions, constants, templates, atomics, tuples, arrays, natives, maps, sets and objects, with object last as the catch-all; an unresolved type parameter is an error. Every type that the analysis reads passes through the first dependency touch, so the transform host learns every declaration file consulted.
17
19
  // @evidence contracts/common.md#clear-and-simple-design One function that is the dispatcher, with each iterator owning one type kind; adding a kind means adding an iterator and a position in the order.
@@ -27,6 +29,16 @@ func Iterate_metadata(props IMetadataIteratorProps) {
27
29
  // files of the whole consulted type graph to the dependency listener the
28
30
  // project transform host registers (see schemas/metadata/MetadataDependency).
29
31
  schemametadata.MetadataDependency_touchType(props.Checker, props.Type)
32
+ if props.Type.Flags()&nativechecker.TypeFlagsESSymbolLike != 0 {
33
+ if props.Errors != nil {
34
+ *props.Errors = append(*props.Errors, MetadataFactory_IError{
35
+ Name: metadata_type_full_name(props.Checker, props.Type, props.Components),
36
+ Explore: props.Explore,
37
+ Messages: []string{unsupportedSymbolValue},
38
+ })
39
+ }
40
+ return
41
+ }
30
42
  if props.Type.IsTypeParameter() == true {
31
43
  if props.Errors != nil {
32
44
  *props.Errors = append(*props.Errors, MetadataFactory_IError{
@@ -42,15 +42,23 @@ func Iterate_metadata_intersection(props IMetadataIteratorProps) bool {
42
42
  }
43
43
 
44
44
  commit := props.Components.Clone()
45
+ types := props.Type.Types()
45
46
  fakeErrors := []MetadataFactory_IError{}
46
- children := make([]*schemametadata.MetadataSchema, 0, len(props.Type.Types()))
47
- for _, typ := range props.Type.Types() {
47
+ type failedTrial struct {
48
+ child *schemametadata.MetadataSchema
49
+ start, end int
50
+ }
51
+ var failed []failedTrial
52
+ children := make([]*schemametadata.MetadataSchema, 0, len(types))
53
+ nonObjectBase := false
54
+ for _, typ := range types {
55
+ start := len(fakeErrors)
48
56
  options := props.Options
49
57
  options.Absorb = true
50
58
  options.Functional = false
51
59
  explore := props.Explore
52
60
  explore.Aliased = false
53
- children = append(children, Explore_metadata(Explore_metadata_IProps{
61
+ child := Explore_metadata(Explore_metadata_IProps{
54
62
  Options: options,
55
63
  Checker: props.Checker,
56
64
  Components: props.Components,
@@ -60,7 +68,29 @@ func Iterate_metadata_intersection(props IMetadataIteratorProps) bool {
60
68
  Intersected: false,
61
69
  NoCache: true,
62
70
  Prunable: true,
63
- }))
71
+ })
72
+ children = append(children, child)
73
+ if len(fakeErrors) > start {
74
+ failed = append(failed, failedTrial{child, start, len(fakeErrors)})
75
+ }
76
+ nonObjectBase = nonObjectBase || len(child.Atomics)+len(child.Constants)+len(child.Templates)+
77
+ len(child.Arrays)+len(child.Tuples)+len(child.Natives)+len(child.Sets)+len(child.Maps) != 0
78
+ }
79
+ // Optional fields can be phantom constraints on a non-object data base.
80
+ // The same fields are real data on an object, including one with a type
81
+ // tag or a call signature.
82
+ if nonObjectBase && len(failed) != 0 {
83
+ kept := fakeErrors[:0]
84
+ for _, trial := range failed {
85
+ phantom := iterate_metadata_intersection_is_removable_brand(trial.child) &&
86
+ !iterate_metadata_intersection_is_type_tag(trial.child.Objects[0].Type)
87
+ for _, err := range fakeErrors[trial.start:trial.end] {
88
+ if !phantom || len(err.Messages) != 1 || err.Messages[0] != unsupportedSymbolValue {
89
+ kept = append(kept, err)
90
+ }
91
+ }
92
+ }
93
+ fakeErrors = kept
64
94
  }
65
95
 
66
96
  escape := func(out bool) bool {
@@ -143,7 +143,7 @@ func (classifyJoinerNamespace) Object(props ClassifyJoiner_ObjectProps) *shimast
143
143
  f.NewElementAccessExpression(output, nil, key, shimast.NodeFlagsNone),
144
144
  nil,
145
145
  f.NewToken(shimast.KindEqualsToken),
146
- entry.Expression,
146
+ cloneJoiner_dynamic_value(entry, props.Emit),
147
147
  )),
148
148
  f.NewContinueStatement(nil),
149
149
  }),
@@ -73,7 +73,7 @@ type CloneJoiner_ArrayProps struct {
73
73
  func (cloneJoinerNamespace) Object(props CloneJoiner_ObjectProps) *shimast.Node {
74
74
  f := nativecontext.NodeFactoryOf(props.Emit)
75
75
  if len(props.Entries) == 0 {
76
- return f.NewIdentifier("{}")
76
+ return f.NewObjectLiteralExpression(f.NewNodeList(nil), false)
77
77
  }
78
78
 
79
79
  regular := []IExpressionEntry{}
@@ -143,7 +143,7 @@ func (cloneJoinerNamespace) Object(props CloneJoiner_ObjectProps) *shimast.Node
143
143
  f.NewElementAccessExpression(output, nil, key, shimast.NodeFlagsNone),
144
144
  nil,
145
145
  f.NewToken(shimast.KindEqualsToken),
146
- entry.Expression,
146
+ cloneJoiner_dynamic_value(entry, props.Emit),
147
147
  ),
148
148
  ),
149
149
  f.NewContinueStatement(nil),
@@ -182,6 +182,19 @@ func (cloneJoinerNamespace) Object(props CloneJoiner_ObjectProps) *shimast.Node
182
182
  )
183
183
  }
184
184
 
185
+ // Index-signature validation can admit a present undefined value. Preserve it
186
+ // without passing it to a decoder that expects the declared value type.
187
+ func cloneJoiner_dynamic_value(entry IExpressionEntry, emit *shimprinter.EmitContext) *shimast.Node {
188
+ f := nativecontext.NodeFactoryOf(emit)
189
+ return nativefactories.ExpressionFactory.Conditional(
190
+ f.NewBinaryExpression(nil, entry.Input, nil, f.NewToken(shimast.KindExclamationEqualsEqualsToken),
191
+ f.NewVoidExpression(f.NewNumericLiteral("0", shimast.TokenFlagsNone))),
192
+ entry.Expression,
193
+ entry.Input,
194
+ emit,
195
+ )
196
+ }
197
+
185
198
  func cloneJoiner_optional_condition(entry IExpressionEntry, input *shimast.Expression, emit ...*shimprinter.EmitContext) *shimast.Node {
186
199
  if entry.StrictOptionalUndefined {
187
200
  return nativefactories.ExpressionFactory.IsRequired(entry.Input, emit...)
@@ -60,7 +60,7 @@ type NotationJoiner_ArrayProps struct {
60
60
  func (notationJoinerNamespace) Object(props NotationJoiner_ObjectProps) *shimast.Node {
61
61
  f := nativecontext.NodeFactoryOf(props.Emit)
62
62
  if len(props.Entries) == 0 {
63
- return f.NewIdentifier("{}")
63
+ return f.NewObjectLiteralExpression(f.NewNodeList(nil), false)
64
64
  }
65
65
 
66
66
  regular := []IExpressionEntry{}
@@ -133,7 +133,7 @@ func (notationJoinerNamespace) Object(props NotationJoiner_ObjectProps) *shimast
133
133
  output,
134
134
  sources,
135
135
  key,
136
- entry.Expression,
136
+ cloneJoiner_dynamic_value(entry, props.Emit),
137
137
  props.DynamicRename(),
138
138
  }),
139
139
  shimast.NodeFlagsNone,
package/native/go.mod CHANGED
@@ -2,7 +2,7 @@ module github.com/samchon/typia/packages/typia/native
2
2
 
3
3
  go 1.26
4
4
 
5
- // The supported ttsc floor (>= 0.36.3, including negotiated emit observations)
5
+ // The supported ttsc floor (>= 0.37.0, including recorded environment inputs)
6
6
  // is enforced through typia's package.json peerDependency, not here: ttsc builds
7
7
  // this plugin from source on the user's machine and its buildSourcePlugin
8
8
  // generates `replace github.com/samchon/ttsc/packages/ttsc v0.0.0 =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typia",
3
- "version": "15.3.0",
3
+ "version": "15.4.0",
4
4
  "description": "Superfast runtime validators with only one line",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -43,11 +43,11 @@
43
43
  "homepage": "https://typia.io",
44
44
  "dependencies": {
45
45
  "randexp": "^0.5.3",
46
- "@typia/interface": "^15.3.0",
47
- "@typia/utils": "^15.3.0"
46
+ "@typia/interface": "^15.4.0",
47
+ "@typia/utils": "^15.4.0"
48
48
  },
49
49
  "peerDependencies": {
50
- "ttsc": ">=0.36.3"
50
+ "ttsc": ">=0.37.0"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "ttsc": {
@@ -58,7 +58,7 @@
58
58
  "@types/node": "^25.3.0",
59
59
  "rimraf": "^6.1.2",
60
60
  "rolldown": "^1.1.5",
61
- "ttsc": "^0.36.3",
61
+ "ttsc": "^0.37.0",
62
62
  "typescript": "7.1.0-dev.20261020.3"
63
63
  },
64
64
  "sideEffects": false,
@@ -7,8 +7,8 @@ import { Resolved } from "@typia/interface";
7
7
  * files, boxed primitives and plain objects are rebuilt. Functions become
8
8
  * undefined; object properties with undefined results are omitted, while
9
9
  * arrays, sets and maps retain them. Weak collections throw. Cycles are not
10
- * tracked, and ordinary objects may invoke their own valueOf or property
11
- * getters.
10
+ * tracked, and ordinary objects may invoke a callable valueOf or property
11
+ * getters. A missing or non-callable valueOf is ordinary data.
12
12
  *
13
13
  * @evidence contracts/common.md#principled-implementation The clone walks the value and rebuilds arrays, sets, maps, boxed primitives, dates, regular expressions, typed arrays, buffers, data views, blobs, files and plain objects, turns functions into undefined, omits object properties whose cloned values are undefined while retaining such array/set/map results, and throws for weak collections. Native recognition checks intrinsic prototype accessors with `Reflect.apply` rather than trusting a supplied string tag or own getter; native clones use those captured accessors for their internal data. The ordinary-object branch invokes valueOf and clones its replacement when different, otherwise rebuilding enumerable own entries. Cycles are not tracked, so a cyclic value does not terminate.
14
14
  * @evidence contracts/common.md#clear-and-simple-design One entry function over a recognition function, a native cloner and a buffer range copier; the accessor captures are module-level constants because they are looked up once from the prototypes.
@@ -108,8 +108,11 @@ const cloneMain = (value: any): any => {
108
108
  else if (value instanceof WeakSet || value instanceof WeakMap)
109
109
  throw new Error("WeakSet and WeakMap are not supported");
110
110
  else {
111
- const primitive: unknown = value.valueOf();
112
- if (primitive !== value) return cloneMain(primitive);
111
+ const valueOf: unknown = value.valueOf;
112
+ if (typeof valueOf === "function") {
113
+ const primitive: unknown = Reflect.apply(valueOf, value, []);
114
+ if (primitive !== value) return cloneMain(primitive);
115
+ }
113
116
  return Object.fromEntries(
114
117
  Object.entries(value)
115
118
  .map(([k, v]) => [k, cloneMain(v)])
package/src/transform.ts CHANGED
@@ -13,7 +13,9 @@ import type { ITtscPlugin, ITtscPluginFactoryContext } from "ttsc";
13
13
  * resolution, so an empty hostInputHashes declaration permits safe descriptor
14
14
  * replay. The native build host supplies generation-owned input observations
15
15
  * and compiler-owned output provenance for ttsc's checked runtime reuse
16
- * protocol.
16
+ * protocol. Its only variable reads outside ttsc's own namespace go through the
17
+ * program's recorded `Env`, so it declares `environmentInputs` and ttsc keys
18
+ * its outputs by the variables it read instead of the whole environment.
17
19
  *
18
20
  * @param context Plugin factory context of ttsc
19
21
  *
@@ -41,6 +43,7 @@ export function createTtscPlugin(
41
43
  capabilities: {
42
44
  emitObservations: true,
43
45
  emitProvenance: true,
46
+ environmentInputs: true,
44
47
  },
45
48
  };
46
49
  }