From e81afb0b700ed8b61b28664972d166852d1a34b1 Mon Sep 17 00:00:00 2001 From: Zerio Date: Mon, 30 Oct 2023 14:13:54 +0100 Subject: [PATCH 1/3] Documentation for `@customName` --- docs/advanced/compiler-annotations.md | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/docs/advanced/compiler-annotations.md b/docs/advanced/compiler-annotations.md index 8fc6348..cf3fa33 100644 --- a/docs/advanced/compiler-annotations.md +++ b/docs/advanced/compiler-annotations.md @@ -174,6 +174,57 @@ local module = require("mymodule"); +## @customName + +**Target elements:** Any declaration statement + +This annotation can be used to rename variables, identifiers, etc. Which is quite handy to get around reserved keywords in Typescript, which you might need to use in Lua. + + + +```typescript title=input.ts +/** @customName test2 */ +function test() {} + +test(); +``` + +```lua title=output.lua +... +function test2(self) +end +test2(_G) +``` + + + + + +```typescript title=input.ts +/** @customName Test2 **/ +namespace Test { + /** @customName Func2 **/ + export function Func(): string { + return "hi"; + } +} + +Test.Func(); +``` + +```lua title=output.lua +... +Test2 = Test2 or ({}) +do + function Test2.Func2(self) + return "hi" + end +end +Test2:Func2() +``` + + + ## @noSelf **Target elements:** `declare class`, `(declare) interface` or `declare namespace` From 1529ae1491c08a564aa489c9ba5fb00b212aab79 Mon Sep 17 00:00:00 2001 From: Zerio Date: Mon, 30 Oct 2023 14:19:55 +0100 Subject: [PATCH 2/3] Improve `@customName` docs --- docs/advanced/compiler-annotations.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/advanced/compiler-annotations.md b/docs/advanced/compiler-annotations.md index cf3fa33..5599555 100644 --- a/docs/advanced/compiler-annotations.md +++ b/docs/advanced/compiler-annotations.md @@ -178,7 +178,11 @@ local module = require("mymodule"); **Target elements:** Any declaration statement -This annotation can be used to rename variables, identifiers, etc. Which is quite handy to get around reserved keywords in Typescript, which you might need to use in Lua. +This decorator can be used to rename variables, identifiers, etc. Meaning that you can name something `x` in your Typescript environment, but then have it compile under the name `y`. + +This can be quite handy to get around some reserved keywords in Typescript, which you might need/want to use in Lua. + +### Example From 49cc269fe0946c069ee79d8309f9968de593b153 Mon Sep 17 00:00:00 2001 From: Zerio Date: Mon, 30 Oct 2023 14:20:56 +0100 Subject: [PATCH 3/3] Update compiler-annotations.md --- docs/advanced/compiler-annotations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advanced/compiler-annotations.md b/docs/advanced/compiler-annotations.md index 5599555..b0a7048 100644 --- a/docs/advanced/compiler-annotations.md +++ b/docs/advanced/compiler-annotations.md @@ -182,7 +182,7 @@ This decorator can be used to rename variables, identifiers, etc. Meaning that y This can be quite handy to get around some reserved keywords in Typescript, which you might need/want to use in Lua. -### Example +**Example**