forked from TypeScriptToLua/TypeScriptToLua.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9ed00105.305bfc96.js
More file actions
1 lines (1 loc) · 11.9 KB
/
Copy path9ed00105.305bfc96.js
File metadata and controls
1 lines (1 loc) · 11.9 KB
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[14],{175:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return m}));var a=n(0),r=n.n(a);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},i=Object.keys(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var b=r.a.createContext({}),p=function(e){var t=r.a.useContext(b),n=t;return e&&(n="function"==typeof e?e(t):l(l({},t),e)),n},u=function(e){var t=p(e.components);return r.a.createElement(b.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},s=r.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,i=e.originalType,o=e.parentName,b=c(e,["components","mdxType","originalType","parentName"]),u=p(n),s=a,m=u["".concat(o,".").concat(s)]||u[s]||d[s]||i;return n?r.a.createElement(m,l(l({ref:t},b),{},{components:n})):r.a.createElement(m,l({ref:t},b))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var i=n.length,o=new Array(i);o[0]=s;var l={};for(var c in t)hasOwnProperty.call(t,c)&&(l[c]=t[c]);l.originalType=e,l.mdxType="string"==typeof e?e:a,o[1]=l;for(var b=2;b<i;b++)o[b]=n[b];return r.a.createElement.apply(null,o)}return r.a.createElement.apply(null,n)}s.displayName="MDXCreateElement"},72:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return i})),n.d(t,"metadata",(function(){return o})),n.d(t,"rightToc",(function(){return l})),n.d(t,"default",(function(){return b}));var a=n(2),r=(n(0),n(175));const i={title:"Configuration"},o={unversionedId:"configuration",id:"configuration",isDocsHomePage:!1,title:"Configuration",description:"TypeScriptToLua uses the same configuration file as the vanilla TypeScript compiler, loading it from the tsconfig.json file using the same rules as tsc.",source:"@site/docs/configuration.md",slug:"/configuration",permalink:"/docs/configuration",editUrl:"https://github.com/TypeScriptToLua/TypeScriptToLua.github.io/edit/source/docs/configuration.md",version:"current",sidebar:"docs",previous:{title:"Getting Started",permalink:"/docs/getting-started"},next:{title:"Caveats",permalink:"/docs/caveats"}},l=[{value:"Custom options",id:"custom-options",children:[]},{value:"Standard options",id:"standard-options",children:[]},{value:"Transformers",id:"transformers",children:[]}],c={rightToc:l};function b({components:e,...t}){return Object(r.b)("wrapper",Object(a.a)({},c,t,{components:e,mdxType:"MDXLayout"}),Object(r.b)("p",null,"TypeScriptToLua uses the same configuration file as the vanilla TypeScript compiler, loading it from the ",Object(r.b)("inlineCode",{parentName:"p"},"tsconfig.json")," file using the same rules as ",Object(r.b)("inlineCode",{parentName:"p"},"tsc"),"."),Object(r.b)("h2",{id:"custom-options"},"Custom options"),Object(r.b)("p",null,"To customize transpilation behavior we add a new group of options to the ",Object(r.b)("inlineCode",{parentName:"p"},"tsconfig.json")," file. All of these options should be placed in a ",Object(r.b)("inlineCode",{parentName:"p"},"tstl")," object."),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:"title=tsconfig.json",title:"tsconfig.json"}),'{\n "tstl": {\n // custom options\n }\n}\n')),Object(r.b)("table",null,Object(r.b)("thead",{parentName:"table"},Object(r.b)("tr",{parentName:"thead"},Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Option"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Values"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Description"))),Object(r.b)("tbody",{parentName:"table"},Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"luaTarget")),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},'"JIT"'),", ",Object(r.b)("inlineCode",{parentName:"td"},'"5.3"'),", ",Object(r.b)("inlineCode",{parentName:"td"},'"5.2"'),", ",Object(r.b)("inlineCode",{parentName:"td"},'"5.1"')," (default: ",Object(r.b)("inlineCode",{parentName:"td"},'"JIT"'),")"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Specifies the Lua version you want to generate code for.")),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"noImplicitSelf")),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"true"),", ",Object(r.b)("inlineCode",{parentName:"td"},"false")," (default: ",Object(r.b)("inlineCode",{parentName:"td"},"false"),")"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"If true, treats all project files as if they were prefixed with",Object(r.b)("br",null),Object(r.b)("inlineCode",{parentName:"td"},"/** @noSelfInFile **/"),".")),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"noHeader")),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"true"),", ",Object(r.b)("inlineCode",{parentName:"td"},"false")," (default: ",Object(r.b)("inlineCode",{parentName:"td"},"false"),")"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Set this to true if you don't want to include our header in the output.")),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"luaLibImport")),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},'"inline"'),", ",Object(r.b)("inlineCode",{parentName:"td"},'"require"'),", ",Object(r.b)("inlineCode",{parentName:"td"},'"always"'),", ",Object(r.b)("inlineCode",{parentName:"td"},'"none"')," (default: ",Object(r.b)("inlineCode",{parentName:"td"},'"require"'),")"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"We polyfill certain JavaScript features with Lua functions, this option specifies how these functions are imported into the Lua output.")),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"sourceMapTraceback")),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"true"),", ",Object(r.b)("inlineCode",{parentName:"td"},"false")," (default: ",Object(r.b)("inlineCode",{parentName:"td"},"false"),")"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Overrides Lua's ",Object(r.b)("inlineCode",{parentName:"td"},"debug.traceback")," to apply sourcemaps to Lua stacktraces. This will make error messages point to your original TypeScript code instead of the generated Lua.")),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"luaBundle")),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"File path (relative to the ",Object(r.b)("inlineCode",{parentName:"td"},"tsconfig.json"),")"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Will bundle all output lua files into a single bundle file. Requires ",Object(r.b)("strong",{parentName:"td"},"luaBundleEntry")," to be set!")),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"luaBundleEntry")),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"File path (relative to the ",Object(r.b)("inlineCode",{parentName:"td"},"tsconfig.json"),")"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"This should be the name/path of the TS file in your project that will serve as entry point to the bundled code.")),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"luaPlugins")),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"Array<{ name: string; import?: string }>")),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"List of ",Object(r.b)("a",Object(a.a)({parentName:"td"},{href:"/docs/api/plugins"}),"TypeScriptToLua plugins"),".")))),Object(r.b)("h2",{id:"standard-options"},"Standard options"),Object(r.b)("p",null,"Most of the standard ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://www.typescriptlang.org/docs/handbook/compiler-options.html"}),"TypeScript options")," work without any changes. Notable unsupported options are:"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"composite"),", ",Object(r.b)("inlineCode",{parentName:"li"},"build")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"incremental")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"emitDecoratorMetadata")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"esModuleInterop"))),Object(r.b)("p",null,"Some options do not apply to TypeScriptToLua and are ignored:"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"outFile")," - use ",Object(r.b)("inlineCode",{parentName:"li"},"luaBundle")," instead."),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"importHelpers"),", ",Object(r.b)("inlineCode",{parentName:"li"},"noEmitHelpers")," - use ",Object(r.b)("inlineCode",{parentName:"li"},"luaLibImport")," instead."),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"target"),", ",Object(r.b)("inlineCode",{parentName:"li"},"module")," - it's only effect is limiting some features, so prefer to set it to ",Object(r.b)("inlineCode",{parentName:"li"},"esnext"),". If TypeScript requires you to specify different ",Object(r.b)("inlineCode",{parentName:"li"},"module")," type because you want to bundle your declarations with ",Object(r.b)("inlineCode",{parentName:"li"},"outFile"),", consider using ",Object(r.b)("a",Object(a.a)({parentName:"li"},{href:"https://api-extractor.com/"}),"API Extractor")," instead.")),Object(r.b)("h2",{id:"transformers"},"Transformers"),Object(r.b)("p",null,"Transformers is a powerful feature of TypeScript that allows you to modify behavior of your program during compilation. While TypeScript ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/microsoft/TypeScript/issues/14419"}),"currently")," does not provide a user-facing way to use transformers, TypeScriptToLua allows you to specify them in the configuration file, following ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/cevek/ttypescript#how-to-use"}),"ttypescript")," format."),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"Example:")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:"title=tsconfig.json",title:"tsconfig.json"}),'{\n "compilerOptions": {\n "plugins": [{ "transform": "dota-lua-types/transformer" }]\n }\n}\n')))}b.isMDXComponent=!0}}]);