ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
117 lines (93 loc) • 6.56 kB
HTML
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>TsSimpleAst</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<link rel="stylesheet" href="/assets/css/style.css?v=71a391c40e7283d83416a246f2c61c5fcb76068a">
<!--
<link rel="stylesheet" href="/assets/css/style.css?v=71a391c40e7283d83416a246f2c61c5fcb76068a">
<link rel="stylesheet" href="/assets/css/custom-style.css?v=71a391c40e7283d83416a246f2c61c5fcb76068a">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/assets/js/main.js"></script>-->
</head>
<body>
<div class="main">
<header class="container">
<div class="row">
<h1 onclick="document.location.href = '/'" class="headerLink">TsSimpleAst</h1>
<!--<p class="subText">Simple way to navigate and manipulate the TypeScript AST.</p>-->
</div>
</header>
<div class="container">
<div class="row">
<div class="col-md-3">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<nav class="sidebar-nav" id="navbarSupportedContent">
<ul class="navbar-nav navbar-default">
<li class="nav-item">
<a class="nav-link" href="/">Overview</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="/setup">Setup</a>
<ul>
<li class="active"><a href="/setup/index">Instantiating</a></li>
<li class=""><a href="/setup/adding-sourcefiles">Adding SourceFiles</a></li>
<li class=""><a href="/setup/diagnostics">Diagnostics</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="/navigation">Navigation</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/manipulation">Manipulation</a>
</li>
<li class="">
<a class="nav-link" href="/details/index">Details</a>
</li>
<li class="nav-item">
<a class="nav-link" href="http://github.com/dsherret/ts-simple-ast">View on GitHub</a>
</li>
</ul>
</nav>
</div>
<section class="container-fluid col-md-9">
<h2 id="instantiating">Instantiating</h2>
<p>Use the default export from <code class="highlighter-rouge">"ts-simple-ast"</code>:</p>
<div class="language-typescript highlighter-rouge"><pre class="highlight"><code><span class="k">import</span> <span class="nx">Ast</span> <span class="k">from</span> <span class="s2">"ts-simple-ast"</span><span class="p">;</span>
<span class="kd">const</span> <span class="nx">ast</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Ast</span><span class="p">();</span>
</code></pre>
</div>
<h3 id="custom-compiler-options">Custom compiler options</h3>
<div class="language-typescript highlighter-rouge"><pre class="highlight"><code><span class="k">import</span> <span class="o">*</span> <span class="k">as</span> <span class="nx">ts</span> <span class="k">from</span> <span class="s2">"typescript"</span><span class="p">;</span>
<span class="kd">const</span> <span class="nx">ast</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Ast</span><span class="p">({</span>
<span class="na">compilerOptions</span><span class="p">:</span> <span class="p">{</span>
<span class="na">target</span><span class="p">:</span> <span class="nx">ts</span><span class="p">.</span><span class="nx">ScriptTarget</span><span class="p">.</span><span class="nx">ES3</span>
<span class="p">}</span>
<span class="p">});</span>
</code></pre>
</div>
<h3 id="custom-tsconfigjson">Custom tsconfig.json</h3>
<p>By default, if a <em>tsconfig.json</em> is found in the current working directory then it will use that file for the <em>tsconfig.json</em>.</p>
<p>If you would like to manually specify the path to a <em>tsconfig.json</em> file then specify that:</p>
<div class="language-typescript highlighter-rouge"><pre class="highlight"><code><span class="kd">const</span> <span class="nx">ast</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Ast</span><span class="p">({</span>
<span class="na">tsConfigFilePath</span><span class="p">:</span> <span class="s2">"path/to/tsconfig.json"</span>
<span class="p">});</span>
</code></pre>
</div>
<p><strong>Next step:</strong> <a href="adding-sourcefiles">Adding SourceFiles</a></p>
</section>
</div>
</div>
<footer>
</footer>
</div>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
</body>
</html>