Repository: babel/babel
File: packages/babel-plugin-transform-typescript/src/index.js (JavaScript)

Code before:
          }
        }

        if (parameterProperties.length) {
          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);
        }
      },
    };

    return {
      name: "transform-typescript",
      inherits: syntaxTypeScript,

      visitor: {
        //"Pattern" alias doesn't include Identifier or RestElement.
        Pattern: visitPattern,
        Identifier: visitPattern,
        RestElement: visitPattern,

        Program(path, state) {
          const { file } = state;
          let fileJsxPragma = null;

          if (!GLOBAL_TYPES.has(path.node)) {
            GLOBAL_TYPES.set(path.node, new Set());
          }

          if (file.ast.comments) {
            for (const comment of (file.ast.comments: Array<Object>)) {
              const jsxMatches = JSX_ANNOTATION_REGEX.exec(comment.value);
              if (jsxMatches) {
                fileJsxPragma = jsxMatches[1];
              }
            }
          }


Review comment (suggestion):
The code for `method` and `constructor` has just been moved here from the lines before, so that all the class members "visitors" are together.

Code after:
            !PARSED_PARAMS.has(param.parameter)
          ) {
            PARSED_PARAMS.add(param.parameter);
            parameterProperties.push(param.parameter);
          }
        }

        if (parameterProperties.length) {
          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);
        }
      },
    };

    return {
      name: "transform-typescript",
      inherits: syntaxTypeScript,

      visitor: {
        //"Pattern" alias doesn't include Identifier or RestElement.
        Pattern: visitPattern,
        Identifier: visitPattern,
        RestElement: visitPattern,

        Program(path, state) {
          const { file } = state;
          let fileJsxPragma = null;

          if (!GLOBAL_TYPES.has(path.node)) {
            GLOBAL_TYPES.set(path.node, new Set());
          }

          if (file.ast.comments) {
            for (const comment of (file.ast.comments: Array<Object>)) {
              const jsxMatches = JSX_ANNOTATION_REGEX.exec(comment.value);
              if (jsxMatches) {
                fileJsxPragma = jsxMatches[1];