@babel/types#expressionStatement TypeScript Examples

The following examples show how to use @babel/types#expressionStatement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: module.ts    From react-native-decompiler with GNU Affero General Public License v3.0 6 votes vote down vote up
calculateFields(): void {
    this.originalCode = generator({
      ...this.originalFile.program,
      type: 'Program',
      body: [expressionStatement(this.rootPath.node)],
    }, { compact: true }).code;

    this.rootPath.traverse({
      StringLiteral: (path) => {
        this.moduleStrings.push(path.node.value);
      },
      Identifier: (path) => {
        if (path.node.name.length > 1) {
          this.variableNames.add(path.node.name);
        }
      },
    });

    this.moduleComments = this.originalFile.comments
      ?.filter((comment) => this.rootPath.node.start && this.rootPath.node.end && comment.start > this.rootPath.node.start && comment.end < this.rootPath.node.end)
      ?.map((comment) => comment.value) || [];
  }
Example #2
Source File: module.ts    From react-native-decompiler with GNU Affero General Public License v3.0 6 votes vote down vote up
calculateFields(): void {
    this.originalCode = generator({
      ...this.originalFile.program,
      type: 'Program',
      body: [expressionStatement(this.rootPath.node)],
    }, { compact: true }).code;

    this.rootPath.traverse({
      StringLiteral: (path) => {
        this.moduleStrings.push(path.node.value);
      },
      Identifier: (path) => {
        if (path.node.name.length > 1) {
          this.variableNames.add(path.node.name);
        }
      },
    });

    this.moduleComments = this.originalFile.comments
      ?.filter((comment) => this.rootPath.node.start && this.rootPath.node.end && comment.start > this.rootPath.node.start && comment.end < this.rootPath.node.end)
      ?.map((comment) => comment.value) || [];
  }
Example #3
Source File: constants.ts    From prettier-plugin-sort-imports with Apache License 2.0 5 votes vote down vote up
newLineNode = expressionStatement(
    stringLiteral(PRETTIER_PLUGIN_SORT_IMPORTS_NEW_LINE),
)
Example #4
Source File: babel-polyfill.ts    From nota with MIT License 5 votes vote down vote up
expressionStatement = (expression: Expression): ExpressionStatement => ({
  type: "ExpressionStatement",
  expression,
  ...baseNode,
})
Example #5
Source File: translate.ts    From nota with MIT License 5 votes vote down vote up
parseExpr = (code: string): Expression => {
  let s = parse(`(${code});`)[0] as ExpressionStatement;
  return s.expression;
}