Conversation
|
Is targeting a video game variant of Lua within the scope of this project? I feel like this could fit better as a plugin for this library. I don't know if plugins have ever been discussed for this project, but I'd imagine a plugin could for example inherit one of the "standard" targets (5.1, 5.2, etc.) and become active if the plugin's target identifier is used in transpilation args. |
|
We were discussing that aswell. I think, as long as we dont have a plugin architecture it is fine having this in here. Mainly because i dont want to maintain a fork, while there is still a lot of work to do here. Also glua is probably one of the most used lua dialects out there. Typescript also has support for jsx (angular, react ....) built-in which is similiar to our situation with videogame versions of lua. |
Import filter for extension/metaextension classes
… extension classes
Also removed debug print from array concat test
Perryvw
left a comment
There was a problem hiding this comment.
Looks good but I really dont like the lualib hacky stuff and disabling of ts-lint. We could either solve it in this PR or merge and definitely have to revisit it later.
src/Transpiler.ts
Outdated
|
|
||
| const imports = node.importClause.namedBindings; | ||
|
|
||
| const reqKeyword = this.getRequireKeyword(); |
There was a problem hiding this comment.
Abbreviation goes against our coding style.
There was a problem hiding this comment.
I forgot to remove that whole getRequireKeyword function. It was used to replace require with include should I keep it or remove it?
There was a problem hiding this comment.
Keep it if it serves a purpose, otherwise remove it.
src/Transpiler.ts
Outdated
|
|
||
| imports.elements.forEach(element => { | ||
| const filteredElements = imports.elements.filter(e => { | ||
| const decs = tsHelper.getCustomDecorators(this.checker.getTypeAtLocation(e), this.checker); |
src/lualib/ArrayConcat.ts
Outdated
| @@ -0,0 +1,24 @@ | |||
| /* tslint:disable */ | |||
There was a problem hiding this comment.
Why is this disabled here? I think we should be linting these files.
| for (let i = 0; i < args.length; i++) { | ||
| const arg = args[i]; | ||
| // Hack because we don't have an isArray function | ||
| if (pcall(() => (arg as any[]).length) && type(arg) !== "string") { |
There was a problem hiding this comment.
Ew, there must be a better way to do this, or maybe we should just do some assumptions here.
There was a problem hiding this comment.
Cant really make assumptions here a type(arg) == "table" check won't work since you are allowed to pass objects to concat.
Only other solution I could think of is iterating the table with pairs and checking if each key is a number, I didn't choose that variant for performance reasons.
src/lualib/ArrayPush.ts
Outdated
| function __TS__ArrayPush<T>(arr: T[], ...items: T[]): number { | ||
| for (const item of items) { | ||
| arr[arr.length] = item; | ||
| /* tslint:disable */ |
There was a problem hiding this comment.
We shouldn't be disabling linting like this. Instead we should just transpile for ... of using a numeric loop to solve it at that level.
There was a problem hiding this comment.
Not really in the scope of this PR.
We could also just disable the for...of rule in our tslint config, I'm not a big fan of that rule anyway.
EDIT: At first this was suposed to add support for glua (garrysmode lua).
Turns out we can just use the JIT lua target instead if we leave the module handling to the user via gmods
includefunctions.This PR contains a bunch of fixes, of bugs that I encountered while testing the transpiler with gmod lua.
Array.push(...antoherArray))this.Somethingwith something being a get accessor