import * as ts from 'typescript'; // TOOD: Remove when tools directory is upgraded to support es6 target interface Map { has(v: V): boolean; set(k: K, v: V): void; get(k: K): V; } interface MapConstructor { new(): Map; } declare var Map: MapConstructor; var a: Array; /** * A symbol table of ts.Symbol to a folded value used during expression folding in Evaluator. * * This is a thin wrapper around a Map<> using the first declaration location instead of the symbol * itself as the key. In the TypeScript binder and type checker, mulitple symbols are sometimes * created for a symbol depending on what scope it is in (e.g. export vs. local). Using the * declaration node as the key results in these duplicate symbols being treated as identical. */ export class Symbols { private map = new Map(); public has(symbol: ts.Symbol): boolean { return this.map.has(symbol.getDeclarations()[0]); } public set(symbol: ts.Symbol, value): void { this.map.set(symbol.getDeclarations()[0], value); } public get(symbol: ts.Symbol): any { return this.map.get(symbol.getDeclarations()[0]); } static empty: Symbols = new Symbols(); }