How to use the @babel/helper-create-class-features-plugin.injectInitialization function in @babel/helper-create-class-features-plugin

To help you get started, we’ve selected a few @babel/helper-create-class-features-plugin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github babel / babel / packages / babel-plugin-transform-typescript / src / index.js View on Github external
const assigns = parameterProperties.map(p => {
            let id;
            if (t.isIdentifier(p)) {
              id = p;
            } else if (t.isAssignmentPattern(p) && t.isIdentifier(p.left)) {
              id = p.left;
            } else {
              throw path.buildCodeFrameError(
                "Parameter properties can not be destructuring patterns.",
              );
            }

            return template.statement.ast`this.${id} = ${id}`;
          });

          injectInitialization(classPath, path, assigns);
        }
      },
    };

@babel/helper-create-class-features-plugin

Compile class public and private fields, private methods and decorators to ES6

MIT
Latest version published 20 hours ago

Package Health Score

95 / 100
Full package analysis