github.com/evanw/esbuild@v0.21.4/internal/runtime/runtime.go (about) 1 package runtime 2 3 // This is esbuild's runtime code. It contains helper functions that are 4 // automatically injected into output files to implement certain features. For 5 // example, the "**" operator is replaced with a call to "__pow" when targeting 6 // ES2015. Tree shaking automatically removes unused code from the runtime. 7 8 import ( 9 "github.com/evanw/esbuild/internal/compat" 10 "github.com/evanw/esbuild/internal/logger" 11 ) 12 13 // The runtime source is always at a special index. The index is always zero 14 // but this constant is always used instead to improve readability and ensure 15 // all code that references this index can be discovered easily. 16 const SourceIndex = uint32(0) 17 18 func Source(unsupportedJSFeatures compat.JSFeature) logger.Source { 19 // Note: These helper functions used to be named similar things to the helper 20 // functions from the TypeScript compiler. However, people sometimes use these 21 // two projects in combination and TypeScript's implementation of these helpers 22 // causes name collisions. Some examples: 23 // 24 // * The "tslib" library will overwrite esbuild's helper functions if the bundled 25 // code is run in the global scope: https://github.com/evanw/esbuild/issues/1102 26 // 27 // * Running the TypeScript compiler on esbuild's output to convert ES6 to ES5 28 // will also overwrite esbuild's helper functions because TypeScript doesn't 29 // change the names of its helper functions to avoid name collisions: 30 // https://github.com/microsoft/TypeScript/issues/43296 31 // 32 // These can both be considered bugs in TypeScript. However, they are unlikely 33 // to be fixed and it's simplest to just avoid using the same names to avoid 34 // these bugs. Forbidden names (from "tslib"): 35 // 36 // __assign 37 // __asyncDelegator 38 // __asyncGenerator 39 // __asyncValues 40 // __await 41 // __awaiter 42 // __classPrivateFieldGet 43 // __classPrivateFieldSet 44 // __createBinding 45 // __decorate 46 // __exportStar 47 // __extends 48 // __generator 49 // __importDefault 50 // __importStar 51 // __makeTemplateObject 52 // __metadata 53 // __param 54 // __read 55 // __rest 56 // __spread 57 // __spreadArray 58 // __spreadArrays 59 // __values 60 // 61 // Note: The "__objRest" function has a for-of loop which requires ES6, but 62 // transforming destructuring to ES5 isn't even supported so it's ok. 63 text := ` 64 var __create = Object.create 65 var __freeze = Object.freeze 66 var __defProp = Object.defineProperty 67 var __defProps = Object.defineProperties 68 var __getOwnPropDesc = Object.getOwnPropertyDescriptor // Note: can return "undefined" due to a Safari bug 69 var __getOwnPropDescs = Object.getOwnPropertyDescriptors 70 var __getOwnPropNames = Object.getOwnPropertyNames 71 var __getOwnPropSymbols = Object.getOwnPropertySymbols 72 var __getProtoOf = Object.getPrototypeOf 73 var __hasOwnProp = Object.prototype.hasOwnProperty 74 var __propIsEnum = Object.prototype.propertyIsEnumerable 75 var __reflectGet = Reflect.get 76 var __reflectSet = Reflect.set 77 78 var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for('Symbol.' + name) 79 var __typeError = msg => { throw TypeError(msg) } 80 81 export var __pow = Math.pow 82 83 var __defNormalProp = (obj, key, value) => key in obj 84 ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) 85 : obj[key] = value 86 87 export var __spreadValues = (a, b) => { 88 for (var prop in b ||= {}) 89 if (__hasOwnProp.call(b, prop)) 90 __defNormalProp(a, prop, b[prop]) 91 if (__getOwnPropSymbols) 92 ` 93 94 // Avoid "of" when not using ES6 95 if !unsupportedJSFeatures.Has(compat.ForOf) { 96 text += ` 97 for (var prop of __getOwnPropSymbols(b)) { 98 ` 99 } else { 100 text += ` 101 for (var props = __getOwnPropSymbols(b), i = 0, n = props.length, prop; i < n; i++) { 102 prop = props[i] 103 ` 104 } 105 106 text += ` 107 if (__propIsEnum.call(b, prop)) 108 __defNormalProp(a, prop, b[prop]) 109 } 110 return a 111 } 112 export var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)) 113 114 // Update the "name" property on the function or class for "--keep-names" 115 export var __name = (target, value) => __defProp(target, 'name', { value, configurable: true }) 116 117 // This fallback "require" function exists so that "typeof require" can 118 // naturally be "function" even in non-CommonJS environments since esbuild 119 // emulates a CommonJS environment (issue #1202). However, people want this 120 // shim to fall back to "globalThis.require" even if it's defined later 121 // (including property accesses such as "require.resolve") so we need to 122 // use a proxy (issue #1614). 123 export var __require = 124 /* @__PURE__ */ (x => 125 typeof require !== 'undefined' ? require : 126 typeof Proxy !== 'undefined' ? new Proxy(x, { 127 get: (a, b) => (typeof require !== 'undefined' ? require : a)[b] 128 }) : x 129 )(function(x) { 130 if (typeof require !== 'undefined') return require.apply(this, arguments) 131 throw Error('Dynamic require of "' + x + '" is not supported') 132 }) 133 134 // This is used for glob imports 135 export var __glob = map => path => { 136 var fn = map[path] 137 if (fn) return fn() 138 throw new Error('Module not found in bundle: ' + path) 139 } 140 141 // For object rest patterns 142 export var __restKey = key => typeof key === 'symbol' ? key : key + '' 143 export var __objRest = (source, exclude) => { 144 var target = {} 145 for (var prop in source) 146 if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) 147 target[prop] = source[prop] 148 if (source != null && __getOwnPropSymbols) 149 ` 150 151 // Avoid "of" when not using ES6 152 if !unsupportedJSFeatures.Has(compat.ForOf) { 153 text += ` 154 for (var prop of __getOwnPropSymbols(source)) { 155 ` 156 } else { 157 text += ` 158 for (var props = __getOwnPropSymbols(source), i = 0, n = props.length, prop; i < n; i++) { 159 prop = props[i] 160 ` 161 } 162 163 text += ` 164 if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) 165 target[prop] = source[prop] 166 } 167 return target 168 } 169 170 // This is for lazily-initialized ESM code. This has two implementations, a 171 // compact one for minified code and a verbose one that generates friendly 172 // names in V8's profiler and in stack traces. 173 export var __esm = (fn, res) => function __init() { 174 return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res 175 } 176 export var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res) 177 178 // Wraps a CommonJS closure and returns a require() function. This has two 179 // implementations, a compact one for minified code and a verbose one that 180 // generates friendly names in V8's profiler and in stack traces. 181 export var __commonJS = (cb, mod) => function __require() { 182 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {exports: {}}).exports, mod), mod.exports 183 } 184 export var __commonJSMin = (cb, mod) => () => (mod || cb((mod = {exports: {}}).exports, mod), mod.exports) 185 186 // Used to implement ESM exports both for "require()" and "import * as" 187 export var __export = (target, all) => { 188 for (var name in all) 189 __defProp(target, name, { get: all[name], enumerable: true }) 190 } 191 192 var __copyProps = (to, from, except, desc) => { 193 if (from && typeof from === 'object' || typeof from === 'function') 194 ` 195 196 // Avoid "let" when not using ES6 197 if !unsupportedJSFeatures.Has(compat.ForOf) && !unsupportedJSFeatures.Has(compat.ConstAndLet) { 198 text += ` 199 for (let key of __getOwnPropNames(from)) 200 if (!__hasOwnProp.call(to, key) && key !== except) 201 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }) 202 ` 203 } else { 204 text += ` 205 for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { 206 key = keys[i] 207 if (!__hasOwnProp.call(to, key) && key !== except) 208 __defProp(to, key, { get: (k => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }) 209 } 210 ` 211 } 212 213 text += ` 214 return to 215 } 216 217 // This is used to implement "export * from" statements. It copies properties 218 // from the imported module to the current module's ESM export object. If the 219 // current module is an entry point and the target format is CommonJS, we 220 // also copy the properties to "module.exports" in addition to our module's 221 // internal ESM export object. 222 export var __reExport = (target, mod, secondTarget) => ( 223 __copyProps(target, mod, 'default'), 224 secondTarget && __copyProps(secondTarget, mod, 'default') 225 ) 226 227 // Converts the module from CommonJS to ESM. When in node mode (i.e. in an 228 // ".mjs" file, package.json has "type: module", or the "__esModule" export 229 // in the CommonJS file is falsy or missing), the "default" property is 230 // overridden to point to the original CommonJS exports object instead. 231 export var __toESM = (mod, isNodeMode, target) => ( 232 target = mod != null ? __create(__getProtoOf(mod)) : {}, 233 __copyProps( 234 // If the importer is in node compatibility mode or this is not an ESM 235 // file that has been converted to a CommonJS file using a Babel- 236 // compatible transform (i.e. "__esModule" has not been set), then set 237 // "default" to the CommonJS "module.exports" for node compatibility. 238 isNodeMode || !mod || !mod.__esModule 239 ? __defProp(target, 'default', { value: mod, enumerable: true }) 240 : target, 241 mod) 242 ) 243 244 // Converts the module from ESM to CommonJS. This clones the input module 245 // object with the addition of a non-enumerable "__esModule" property set 246 // to "true", which overwrites any existing export named "__esModule". 247 export var __toCommonJS = mod => __copyProps(__defProp({}, '__esModule', { value: true }), mod) 248 249 // For TypeScript experimental decorators 250 // - kind === undefined: class 251 // - kind === 1: method, parameter 252 // - kind === 2: field 253 export var __decorateClass = (decorators, target, key, kind) => { 254 var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target 255 for (var i = decorators.length - 1, decorator; i >= 0; i--) 256 if (decorator = decorators[i]) 257 result = (kind ? decorator(target, key, result) : decorator(result)) || result 258 if (kind && result) __defProp(target, key, result) 259 return result 260 } 261 export var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index) 262 263 // For JavaScript decorators 264 export var __decoratorStart = base => [, , , __create(base?.[__knownSymbol('metadata')] ?? null)] 265 var __decoratorStrings = ['class', 'method', 'getter', 'setter', 'accessor', 'field', 'value', 'get', 'set'] 266 var __expectFn = fn => fn !== void 0 && typeof fn !== 'function' ? __typeError('Function expected') : fn 267 var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: fn => 268 done._ ? __typeError('Already initialized') : fns.push(__expectFn(fn || null)) }) 269 export var __runInitializers = (array, flags, self, value) => { 270 for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value) 271 return value 272 } 273 export var __decorateElement = (array, flags, name, decorators, target, extra) => { 274 var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16) 275 var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5] 276 var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []) 277 var desc = k && ( 278 !p && !s && (target = target.prototype), 279 k < 5 && (k > 3 || !p) && 280 ` 281 282 // Avoid object extensions when not using ES6 283 if !unsupportedJSFeatures.Has(compat.ObjectExtensions) { 284 text += `__getOwnPropDesc(k < 4 ? target : { get [name]() { return __privateGet(this, extra) }, set [name](x) { return __privateSet(this, extra, x) } }, name)` 285 } else { 286 text += `(k < 4 ? __getOwnPropDesc(target, name) : { get: () => __privateGet(this, extra), set: x => __privateSet(this, extra, x) })` 287 } 288 289 text += ` 290 ) 291 k ? p && k < 4 && __name(extra, (k > 2 ? 'set ' : k > 1 ? 'get ' : '') + name) : __name(target, name) 292 293 for (var i = decorators.length - 1; i >= 0; i--) { 294 ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers) 295 296 if (k) { 297 ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? x => __privateIn(target, x) : x => name in x } 298 if (k ^ 3) access.get = p ? x => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : x => x[name] 299 if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y 300 } 301 302 it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1 303 304 if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it) 305 else if (typeof it !== 'object' || it === null) __typeError('Object expected') 306 else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn) 307 } 308 309 return k || (target[__knownSymbol('metadata')] = array[3]), 310 desc && __defProp(target, name, desc), 311 p ? k ^ 4 ? extra : desc : target 312 } 313 314 // For class members 315 export var __publicField = (obj, key, value) => ( 316 __defNormalProp(obj, typeof key !== 'symbol' ? key + '' : key, value) 317 ) 318 var __accessCheck = (obj, member, msg) => ( 319 member.has(obj) || __typeError('Cannot ' + msg) 320 ) 321 export var __privateIn = (member, obj) => ( 322 Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : 323 member.has(obj) 324 ) 325 export var __privateGet = (obj, member, getter) => ( 326 __accessCheck(obj, member, 'read from private field'), 327 getter ? getter.call(obj) : member.get(obj) 328 ) 329 export var __privateAdd = (obj, member, value) => ( 330 member.has(obj) ? __typeError('Cannot add the same private member more than once') : 331 member instanceof WeakSet ? member.add(obj) : member.set(obj, value) 332 ) 333 export var __privateSet = (obj, member, value, setter) => ( 334 __accessCheck(obj, member, 'write to private field'), 335 setter ? setter.call(obj, value) : member.set(obj, value), 336 value 337 ) 338 export var __privateMethod = (obj, member, method) => ( 339 __accessCheck(obj, member, 'access private method'), 340 method 341 ) 342 export var __earlyAccess = (name) => { 343 throw ReferenceError('Cannot access "' + name + '" before initialization') 344 } 345 ` 346 347 if !unsupportedJSFeatures.Has(compat.ObjectAccessors) { 348 text += ` 349 export var __privateWrapper = (obj, member, setter, getter) => ({ 350 set _(value) { __privateSet(obj, member, value, setter) }, 351 get _() { return __privateGet(obj, member, getter) }, 352 }) 353 ` 354 } else { 355 text += ` 356 export var __privateWrapper = (obj, member, setter, getter) => __defProp({}, '_', { 357 set: value => __privateSet(obj, member, value, setter), 358 get: () => __privateGet(obj, member, getter), 359 }) 360 ` 361 } 362 363 text += ` 364 // For "super" property accesses 365 export var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj) 366 export var __superSet = (cls, obj, key, val) => (__reflectSet(__getProtoOf(cls), key, val, obj), val) 367 ` 368 369 if !unsupportedJSFeatures.Has(compat.ObjectAccessors) { 370 text += ` 371 export var __superWrapper = (cls, obj, key) => ({ 372 get _() { return __superGet(cls, obj, key) }, 373 set _(val) { __superSet(cls, obj, key, val) }, 374 }) 375 ` 376 } else { 377 text += ` 378 export var __superWrapper = (cls, obj, key) => __defProp({}, '_', { 379 get: () => __superGet(cls, obj, key), 380 set: val => __superSet(cls, obj, key, val), 381 }) 382 ` 383 } 384 385 text += ` 386 // For lowering tagged template literals 387 export var __template = (cooked, raw) => __freeze(__defProp(cooked, 'raw', { value: __freeze(raw || cooked.slice()) })) 388 389 // This helps for lowering async functions 390 export var __async = (__this, __arguments, generator) => { 391 return new Promise((resolve, reject) => { 392 var fulfilled = value => { 393 try { 394 step(generator.next(value)) 395 } catch (e) { 396 reject(e) 397 } 398 } 399 var rejected = value => { 400 try { 401 step(generator.throw(value)) 402 } catch (e) { 403 reject(e) 404 } 405 } 406 var step = x => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected) 407 step((generator = generator.apply(__this, __arguments)).next()) 408 }) 409 } 410 411 // These help for lowering async generator functions 412 export var __await = function (promise, isYieldStar) { 413 this[0] = promise 414 this[1] = isYieldStar 415 } 416 export var __asyncGenerator = (__this, __arguments, generator) => { 417 var resume = (k, v, yes, no) => { 418 try { 419 var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done 420 Promise.resolve(isAwait ? v[0] : v) 421 .then(y => isAwait 422 ? resume(k === 'return' ? k : 'next', v[1] ? { done: y.done, value: y.value } : y, yes, no) 423 : yes({ value: y, done })) 424 .catch(e => resume('throw', e, yes, no)) 425 } catch (e) { 426 no(e) 427 } 428 }, method = k => it[k] = x => new Promise((yes, no) => resume(k, x, yes, no)), it = {} 429 return generator = generator.apply(__this, __arguments), 430 it[__knownSymbol('asyncIterator')] = () => it, 431 method('next'), 432 method('throw'), 433 method('return'), 434 it 435 } 436 export var __yieldStar = value => { 437 var obj = value[__knownSymbol('asyncIterator')], isAwait = false, method, it = {} 438 if (obj == null) { 439 obj = value[__knownSymbol('iterator')]() 440 method = k => it[k] = x => obj[k](x) 441 } else { 442 obj = obj.call(value) 443 method = k => it[k] = v => { 444 if (isAwait) { 445 isAwait = false 446 if (k === 'throw') throw v 447 return v 448 } 449 isAwait = true 450 return { 451 done: false, 452 value: new __await(new Promise(resolve => { 453 var x = obj[k](v) 454 if (!(x instanceof Object)) __typeError('Object expected') 455 resolve(x) 456 }), 1), 457 } 458 } 459 } 460 return it[__knownSymbol('iterator')] = () => it, 461 method('next'), 462 'throw' in obj ? method('throw') : it.throw = x => { throw x }, 463 'return' in obj && method('return'), 464 it 465 } 466 467 // This helps for lowering for-await loops 468 export var __forAwait = (obj, it, method) => 469 (it = obj[__knownSymbol('asyncIterator')]) 470 ? it.call(obj) 471 : (obj = obj[__knownSymbol('iterator')](), 472 it = {}, 473 method = (key, fn) => 474 (fn = obj[key]) && (it[key] = arg => 475 new Promise((yes, no, done) => ( 476 arg = fn.call(obj, arg), 477 done = arg.done, 478 Promise.resolve(arg.value) 479 .then(value => yes({ value, done }), no) 480 ))), 481 method('next'), 482 method('return'), 483 it) 484 485 // This is for the "binary" loader (custom code is ~2x faster than "atob") 486 export var __toBinaryNode = base64 => new Uint8Array(Buffer.from(base64, 'base64')) 487 export var __toBinary = /* @__PURE__ */ (() => { 488 var table = new Uint8Array(128) 489 for (var i = 0; i < 64; i++) table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i 490 return base64 => { 491 var n = base64.length, bytes = new Uint8Array((n - (base64[n - 1] == '=') - (base64[n - 2] == '=')) * 3 / 4 | 0) 492 for (var i = 0, j = 0; i < n;) { 493 var c0 = table[base64.charCodeAt(i++)], c1 = table[base64.charCodeAt(i++)] 494 var c2 = table[base64.charCodeAt(i++)], c3 = table[base64.charCodeAt(i++)] 495 bytes[j++] = (c0 << 2) | (c1 >> 4) 496 bytes[j++] = (c1 << 4) | (c2 >> 2) 497 bytes[j++] = (c2 << 6) | c3 498 } 499 return bytes 500 } 501 })() 502 503 // These are for the "using" statement in TypeScript 5.2+ 504 export var __using = (stack, value, async) => { 505 if (value != null) { 506 if (typeof value !== 'object' && typeof value !== 'function') __typeError('Object expected') 507 var dispose 508 if (async) dispose = value[__knownSymbol('asyncDispose')] 509 if (dispose === void 0) dispose = value[__knownSymbol('dispose')] 510 if (typeof dispose !== 'function') __typeError('Object not disposable') 511 stack.push([async, dispose, value]) 512 } else if (async) { 513 stack.push([async]) 514 } 515 return value 516 } 517 export var __callDispose = (stack, error, hasError) => { 518 var E = typeof SuppressedError === 'function' ? SuppressedError : 519 function (e, s, m, _) { return _ = Error(m), _.name = 'SuppressedError', _.error = e, _.suppressed = s, _ } 520 var fail = e => error = hasError ? new E(e, error, 'An error was suppressed during disposal') : (hasError = true, e) 521 var next = (it) => { 522 while (it = stack.pop()) { 523 try { 524 var result = it[1] && it[1].call(it[2]) 525 if (it[0]) return Promise.resolve(result).then(next, (e) => (fail(e), next())) 526 } catch (e) { 527 fail(e) 528 } 529 } 530 if (hasError) throw error 531 } 532 return next() 533 } 534 ` 535 536 return logger.Source{ 537 Index: SourceIndex, 538 KeyPath: logger.Path{Text: "<runtime>"}, 539 PrettyPath: "<runtime>", 540 IdentifierName: "runtime", 541 Contents: text, 542 } 543 } 544 545 // The TypeScript decorator transform behaves similar to the official 546 // TypeScript compiler. 547 // 548 // One difference is that the "__decorateClass" function doesn't contain a reference 549 // to the non-existent "Reflect.decorate" function. This function was never 550 // standardized and checking for it is wasted code (as well as a potentially 551 // dangerous cause of unintentional behavior changes in the future). 552 // 553 // Another difference is that the "__decorateClass" function doesn't take in an 554 // optional property descriptor like it does in the official TypeScript 555 // compiler's support code. This appears to be a dead code path in the official 556 // support code that is only there for legacy reasons. 557 // 558 // Here are some examples of how esbuild's decorator transform works: 559 // 560 // ============================= Class decorator ============================== 561 // 562 // // TypeScript // JavaScript 563 // @dec let C = class { 564 // class C { }; 565 // } C = __decorateClass([ 566 // dec 567 // ], C); 568 // 569 // ============================ Method decorator ============================== 570 // 571 // // TypeScript // JavaScript 572 // class C { class C { 573 // @dec foo() {} 574 // foo() {} } 575 // } __decorateClass([ 576 // dec 577 // ], C.prototype, 'foo', 1); 578 // 579 // =========================== Parameter decorator ============================ 580 // 581 // // TypeScript // JavaScript 582 // class C { class C { 583 // foo(@dec bar) {} foo(bar) {} 584 // } } 585 // __decorateClass([ 586 // __decorateParam(0, dec) 587 // ], C.prototype, 'foo', 1); 588 // 589 // ============================= Field decorator ============================== 590 // 591 // // TypeScript // JavaScript 592 // class C { class C { 593 // @dec constructor() { 594 // foo = 123 this.foo = 123 595 // } } 596 // } 597 // __decorateClass([ 598 // dec 599 // ], C.prototype, 'foo', 2);