Files
scriptc/tests/corpus/class-brand-overload.js
T
Chris Tate d3dfdade8e Compile three.js math modules with LLVM
- Run published three.js vector, matrix, and quaternion operations natively and as Wasm without a JavaScript engine.
- Preserve shared class prototype data and JavaScript overload arguments.
- Support Math function values and distinct npm import and require entries.
2026-09-29 20:58:04 -05:00

16 lines
607 B
JavaScript

class Point {
static { Point.prototype.isPoint = true; }
constructor(x = 0) { this.x = x; }
}
/** @param {number} [value] */
function scalar(value) { return value === undefined ? 'missing' : value.toString(); }
/** @param {number|Point} value */
function coordinate(value) {
if (value.isPoint) return scalar(value.x);
return scalar(value);
}
console.log(coordinate(7), coordinate(new Point(9)), coordinate(0));
/** @param {number|Point|undefined} value */
function optionalBrand(value) { return value?.isPoint; }
console.log(optionalBrand(undefined), optionalBrand(2), optionalBrand(new Point(3)));