How to use the @typescript-eslint/typescript-estree.AST_NODE_TYPES.MemberExpression function in @typescript-eslint/typescript-estree

To help you get started, we’ve selected a few @typescript-eslint/typescript-estree 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 Halliwood / ts2lua / src / gen / LuaMaker.ts View on Github external
import util = require('util');
import path = require('path');
import { TsClassInfo, TsEnumInfo, TsModuleInfo } from './TsCollector';
import { TranslateOption } from './TranslateOption';
import { stringify } from 'querystring';

export class LuaMaker {
  private readonly noBraceTypes = [AST_NODE_TYPES.MemberExpression, AST_NODE_TYPES.ThisExpression, AST_NODE_TYPES.Identifier, AST_NODE_TYPES.CallExpression, AST_NODE_TYPES.TSAsExpression, AST_NODE_TYPES.TSTypeAssertion, AST_NODE_TYPES.Super];

  // TODO: Typeof's return value may be different between ts and lua
  private readonly tsType2luaType = {
    'undefined': 'nil',
    'object': 'table'
  };

  private readonly ignoreExpressionType = [AST_NODE_TYPES.MemberExpression, AST_NODE_TYPES.Identifier];
  
  private readonly luaKeyWords = ['and', 'break', 'do', 'else', 'elseif', 'end', 'false', 'for', 'function', 'if', 'in', 'local', 'nil', 'not', 'or', 'repeat', 'return', 'then', 'true', 'until', 'while'];
  
  private pv = 0;
  private readonly operatorPriorityMap: { [opt: string]: number } = {};

  constructor() {
    this.setPriority(['( … )'], this.pv++);
    this.setPriority(['… . …', '… [ … ]', 'new … ( … )', '… ( … )'], this.pv++);
    this.setPriority(['new …'], this.pv++);
    this.setPriority(['… ++', '… --'], this.pv++);
    this.setPriority(['! …', '~ …', '+ …', '- …', '++ …', '-- …', 'typeof …', 'void …', 'delete …', 'await …'], this.pv++);
    this.setPriority(['… ** …'], this.pv++);
    this.setPriority(['… * …', '… / …', '… % …'], this.pv++);
    this.setPriority(['… + …', '… - …'], this.pv++);
    this.setPriority(['… << …', '… >> …', '… >>> …'], this.pv++);
github Halliwood / ts2lua / src / gen / LuaMaker.ts View on Github external
case AST_NODE_TYPES.AssignmentExpression:
        {
          let ae = ast as AssignmentExpression;
          ast.__calPriority = this.getPriority('… ' + ae.operator + ' …');
        }
        break;
  
      case AST_NODE_TYPES.LogicalExpression:
        {
          let le = ast as LogicalExpression;
          ast.__calPriority = this.getPriority('… ' + le.operator + ' …');
        }
        break;
  
      case AST_NODE_TYPES.MemberExpression:
        {
          let me = ast as MemberExpression;
          ast.__calPriority = this.getPriority(me.computed ? '… [ … ]' : '… . …');
        }
        break;
  
      case AST_NODE_TYPES.ConditionalExpression:
        {
          ast.__calPriority = this.getPriority('… ? … : …');
        }
        break;
  
      case AST_NODE_TYPES.CallExpression:
        {
          ast.__calPriority = this.getPriority('… ( … )');
        }

@typescript-eslint/typescript-estree

A parser that converts TypeScript source code into an ESTree compatible form

BSD-2-Clause
Latest version published 8 days ago

Package Health Score

95 / 100
Full package analysis