forked from TypeScriptToLua/TypeScriptToLua.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
72 lines (40 loc) · 16.5 KB
/
index.html
File metadata and controls
72 lines (40 loc) · 16.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="generator" content="Docusaurus v2.0.0-alpha.50">
<title data-react-helmet="true">Configuration | TypeScriptToLua</title>
<meta data-react-helmet="true" name="twitter:card" content="summary_large_image"><meta data-react-helmet="true" property="og:title" content="Configuration | TypeScriptToLua"><meta data-react-helmet="true" name="description" content="TypeScriptToLua uses the same configuration file as the vanilla TypeScript compiler, loading it from the `tsconfig.json` file using the same rules as `tsc`."><meta data-react-helmet="true" property="og:description" content="TypeScriptToLua uses the same configuration file as the vanilla TypeScript compiler, loading it from the `tsconfig.json` file using the same rules as `tsc`."><meta data-react-helmet="true" property="og:url" content="https://typescripttolua.github.io/docs/configuration">
<link data-react-helmet="true" rel="shortcut icon" href="/images/favicon.ico">
<link rel="stylesheet" href="/styles.38eff7c3.css">
<link rel="stylesheet" href="/main.69618293.css">
<link rel="stylesheet" href="/1be78505.0edf629a.css">
<link rel="preload" href="/styles.d96b78fc.js" as="script">
<link rel="preload" href="/runtime~main.80315467.js" as="script">
<link rel="preload" href="/main.fe444d48.js" as="script">
<link rel="preload" href="/1.26a7f959.js" as="script">
<link rel="preload" href="/2.37c71318.js" as="script">
<link rel="preload" href="/3.429ea9f3.js" as="script">
<link rel="preload" href="/1be78505.22fb902e.js" as="script">
<link rel="preload" href="/20ac7829.5357fb4c.js" as="script">
<link rel="preload" href="/17896441.c4b65510.js" as="script">
<link rel="preload" href="/9ed00105.bae6ac6f.js" as="script">
</head>
<body>
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=window.matchMedia("(prefers-color-scheme: dark)"),n=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();null!==n?t(n):e.matches&&t("dark")}()</script>
<div id="__docusaurus">
<nav class="navbar navbar--light navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><div aria-label="Navigation bar toggle" class="navbar__toggle" role="button" tabindex="0"><svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></div><a aria-current="page" class="navbar__brand active" href="/"><img class="navbar__logo" src="/images/logo.png"><strong class="navbar__title">TypeScriptToLua</strong></a><a class="navbar__item navbar__link" href="/docs/getting-started">Docs</a><a class="navbar__item navbar__link" href="/play">Playground</a></div><div class="navbar__items navbar__items--right"><a target="_blank" rel="noopener noreferrer" href="https://discord.gg/BWAq58Y" class="navbar__item navbar__link">Discord</a><a target="_blank" rel="noopener noreferrer" href="https://github.com/TypeScriptToLua/TypeScriptToLua" class="navbar__item navbar__link">GitHub</a><div class="react-toggle react-toggle--disabled displayOnlyInLargeViewport_1gtM"><div class="react-toggle-track"><div class="react-toggle-track-check"><span class="toggle_keGJ moon_1gwN"></span></div><div class="react-toggle-track-x"><span class="toggle_keGJ sun_3CPA"></span></div></div><div class="react-toggle-thumb"></div><input type="checkbox" disabled="" aria-label="Dark mode toggle" class="react-toggle-screenreader-only"></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div><div class="navbar-sidebar"><div class="navbar-sidebar__brand"><a aria-current="page" class="navbar__brand active" href="/"><img class="navbar__logo" src="/images/logo.png"><strong class="navbar__title">TypeScriptToLua</strong></a></div><div class="navbar-sidebar__items"><div class="menu"><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/getting-started">Docs</a></li><li class="menu__list-item"><a class="menu__link" href="/play">Playground</a></li><li class="menu__list-item"><a target="_blank" rel="noopener noreferrer" href="https://discord.gg/BWAq58Y" class="menu__link">Discord</a></li><li class="menu__list-item"><a target="_blank" rel="noopener noreferrer" href="https://github.com/TypeScriptToLua/TypeScriptToLua" class="menu__link">GitHub</a></li></ul></div></div></div></nav><div class="main-wrapper"><div class="docPage_1kjD"><div class="docSidebarContainer_1cYp"><div class="sidebar_1kLs"><div class="menu menu--responsive menu_w2sC"><button aria-label="Open Menu" aria-haspopup="true" class="button button--secondary button--sm menu__button" type="button"><svg aria-label="Menu" class="sidebarMenuIcon_2vk4" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 32 32" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/getting-started">Getting Started</a></li><li class="menu__list-item"><a aria-current="page" class="menu__link menu__link--active" href="/docs/configuration">Configuration</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/caveats">Caveats</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/editor-support">Editor Support</a></li><li class="menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#!">Advanced</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/advanced/writing-declarations">Writing Declarations</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/advanced/compiler-annotations">Compiler Annotations</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/advanced/functions-and-the-self-parameter">Functions and the `self` Parameter</a></li></ul></li><li class="menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#!">API</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/api/overview">Overview</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/api/plugins">Plugins</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/api/printer">Printer</a></li></ul></li></ul></div></div></div><main class="docMainContainer_FFX1"><div class="padding-vert--lg"><div class="container"><div class="row"><div class="col docItemCol_2GOA"><div class="docItemContainer_2cwg"><article><header><h1 class="docTitle_1vWb">Configuration</h1></header><div class="markdown"><p>TypeScriptToLua uses the same configuration file as the vanilla TypeScript compiler, loading it from the <code>tsconfig.json</code> file using the same rules as <code>tsc</code>.</p><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_ZqCz" id="custom-options"></a><a aria-hidden="true" tabindex="-1" class="hash-link" href="#custom-options" title="Direct link to heading">#</a>Custom options</h2><p>To customize transpilation behavior we add a new group of options to the <code>tsconfig.json</code> file. All of these options should be placed in a <code>tstl</code> object.</p><div class="mdxCodeBlock_iHAB"><div class="title_1twf">tsconfig.json</div><pre class="prism-code language-json codeBlock_222H hasTitle_1PmY"><button type="button" aria-label="Copy code to clipboard" class="copyButton_ujp3">Copy</button><code class="codeBlockLines_3zpG" style="color:#393A34;background-color:#f6f8fa"><div class="token-line" style="color:#393A34"><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span></div><div class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token property" style="color:#36acaa">"tstl"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span></div><div class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// custom options</span><span class="token plain"></span></div><div class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span></div></code></pre></div><table><thead><tr><th>Option</th><th>Values</th><th>Description</th></tr></thead><tbody><tr><td><code>luaTarget</code></td><td><code>"JIT"</code>, <code>"5.3"</code>, <code>"5.2"</code>, <code>"5.1"</code> (default: <code>"JIT"</code>)</td><td>Specifies the Lua version you want to generate code for.</td></tr><tr><td><code>noImplicitSelf</code></td><td><code>true</code>, <code>false</code> (default: <code>false</code>)</td><td>If true, treats all project files as if they were prefixed with<br><code>/** @noSelfInFile **/</code>.</td></tr><tr><td><code>noHeader</code></td><td><code>true</code>, <code>false</code> (default: <code>false</code>)</td><td>Set this to true if you don't want to include our header in the output.</td></tr><tr><td><code>luaLibImport</code></td><td><code>"inline"</code>, <code>"require"</code>, <code>"always"</code>, <code>"none"</code> (default: <code>"require"</code>)</td><td>We polyfill certain JavaScript features with Lua functions, this option specifies how these functions are imported into the Lua output.</td></tr><tr><td><code>sourceMapTraceback</code></td><td><code>true</code>, <code>false</code> (default: <code>false</code>)</td><td>Overrides Lua's <code>debug.traceback</code> to apply sourcemaps to Lua stacktraces. This will make error messages point to your original TypeScript code instead of the generated Lua.</td></tr><tr><td><code>luaBundle</code></td><td>File path (relative to the <code>tsconfig.json</code>)</td><td>Will bundle all output lua files into a single bundle file. Requires <strong>luaBundleEntry</strong> to be set!</td></tr><tr><td><code>luaBundleEntry</code></td><td>File path (relative to the <code>tsconfig.json</code>)</td><td>This should be the name/path of the TS file in your project that will serve as entry point to the bundled code.</td></tr><tr><td><code>luaPlugins</code></td><td><code>Array<{ name: string; import?: string }></code></td><td>List of <a href="plugins.md">TypeScriptToLua plugins</a>.</td></tr></tbody></table><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_ZqCz" id="standard-options"></a><a aria-hidden="true" tabindex="-1" class="hash-link" href="#standard-options" title="Direct link to heading">#</a>Standard options</h2><p>Most of the standard <a href="https://www.typescriptlang.org/docs/handbook/compiler-options.html">TypeScript options</a> work without any changes. Notable unsupported options are:</p><ul><li><code>composite</code>, <code>build</code></li><li><code>incremental</code></li><li><code>emitDecoratorMetadata</code></li><li><code>esModuleInterop</code></li></ul><p>Some options do not apply to TypeScriptToLua and are ignored:</p><ul><li><code>outFile</code> - use <code>luaBundle</code> instead.</li><li><code>importHelpers</code>, <code>noEmitHelpers</code> - use <code>luaLibImport</code> instead.</li><li><code>target</code>, <code>module</code> - it's only effect is limiting some features, so prefer to set it to <code>esnext</code>. If TypeScript requires you to specify different <code>module</code> type because you want to bundle your declarations with <code>outFile</code>, consider using <a href="https://api-extractor.com/">API Extractor</a> instead.</li></ul><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_ZqCz" id="transformers"></a><a aria-hidden="true" tabindex="-1" class="hash-link" href="#transformers" title="Direct link to heading">#</a>Transformers</h2><p>Transformers is a powerful feature of TypeScript that allows you to modify behavior of your program during compilation. While TypeScript <a href="https://github.com/microsoft/TypeScript/issues/14419">currently</a> does not provide a user-facing way to use transformers, TypeScriptToLua allows you to specify them in the configuration file, following <a href="https://github.com/cevek/ttypescript#how-to-use">ttypescript</a> format.</p><p><strong>Example:</strong></p><div class="mdxCodeBlock_iHAB"><div class="title_1twf">tsconfig.json</div><pre class="prism-code language-json codeBlock_222H hasTitle_1PmY"><button type="button" aria-label="Copy code to clipboard" class="copyButton_ujp3">Copy</button><code class="codeBlockLines_3zpG" style="color:#393A34;background-color:#f6f8fa"><div class="token-line" style="color:#393A34"><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span></div><div class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token property" style="color:#36acaa">"compilerOptions"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span></div><div class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token property" style="color:#36acaa">"plugins"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"transform"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"dota-lua-types/transformer"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"></span></div><div class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span></div><div class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span></div></code></pre></div></div></article><div class="margin-vert--xl"><div class="row"><div class="col"><a href="https://github.com/TypeScriptToLua/TypeScriptToLua.github.io/edit/source/docs/configuration.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="1.2em" width="1.2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 40 40" style="margin-right:0.3em;vertical-align:sub"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div></div></div><div class="margin-vert--lg"><nav class="pagination-nav"><div class="pagination-nav__item"><a class="pagination-nav__link" href="/docs/getting-started"><div class="pagination-nav__link--sublabel">Previous</div><div class="pagination-nav__link--label">« Getting Started</div></a></div><div class="pagination-nav__item pagination-nav__item--next"><a class="pagination-nav__link" href="/docs/caveats"><div class="pagination-nav__link--sublabel">Next</div><div class="pagination-nav__link--label">Caveats »</div></a></div></nav></div></div></div><div class="col col--3"><div class="tableOfContents_TbNY"><ul class="contents contents__left-border"><li><a href="#custom-options" class="contents__link">Custom options</a></li><li><a href="#standard-options" class="contents__link">Standard options</a></li><li><a href="#transformers" class="contents__link">Transformers</a></li></ul></div></div></div></div></div></main></div></div>
</div>
<script src="/styles.d96b78fc.js"></script>
<script src="/runtime~main.80315467.js"></script>
<script src="/main.fe444d48.js"></script>
<script src="/1.26a7f959.js"></script>
<script src="/2.37c71318.js"></script>
<script src="/3.429ea9f3.js"></script>
<script src="/1be78505.22fb902e.js"></script>
<script src="/20ac7829.5357fb4c.js"></script>
<script src="/17896441.c4b65510.js"></script>
<script src="/9ed00105.bae6ac6f.js"></script>
</body>
</html>