source: trip-planner-front/node_modules/@babel/preset-modules/lib/plugins/transform-async-arrows-in-class/index.js@ 6a80231

Last change on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1"use strict";
2
3exports.__esModule = true;
4exports.default = void 0;
5
6/**
7 * Safari 10.3 had an issue where async arrow function expressions within any class method would throw.
8 * After an initial fix, any references to the instance via `this` within those methods would also throw.
9 * This is fixed by converting arrow functions in class methods into equivalent function expressions.
10 * @see https://bugs.webkit.org/show_bug.cgi?id=166879
11 *
12 * @example
13 * class X{ a(){ async () => {}; } } // throws
14 * class X{ a(){ async function() {}; } } // works
15 *
16 * @example
17 * class X{ a(){
18 * async () => this.a; // throws
19 * } }
20 * class X{ a(){
21 * var _this=this;
22 * async function() { return _this.a }; // works
23 * } }
24 */
25const OPTS = {
26 allowInsertArrow: false,
27 specCompliant: false
28};
29
30var _default = ({
31 types: t
32}) => ({
33 name: "transform-async-arrows-in-class",
34 visitor: {
35 ArrowFunctionExpression(path) {
36 if (path.node.async && path.findParent(t.isClassMethod)) {
37 path.arrowFunctionToExpression(OPTS);
38 }
39 }
40
41 }
42});
43
44exports.default = _default;
45module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.