Conversation
| @@ -1,4 +1,4 @@ | |||
| function __TS__ArrayConcat(this: void, arr1: any[], ...args: any[]): any[] { | |||
| export function __TS__ArrayConcat(this: void, arr1: any[], ...args: any[]): any[] { | |||
There was a problem hiding this comment.
Is it possible to make Array a class like set/map?
To give people the ability to overwrite array built ins.
EDIT: same applies to Object
There was a problem hiding this comment.
that might cause problems when interacting with existing lua code. Could be done in separate PR, see #262
There was a problem hiding this comment.
i think it would be annoying for end users to have to mix Array and LuaArray, for example my game API returns lots of LuaArray
There was a problem hiding this comment.
Out of scope for this PR, this should be considered in a separate PR.
|
I tried out this PR today with my mod, and everything seems to be working great so far. |
| @@ -1,4 +1,4 @@ | |||
| function __TS__ArrayConcat(this: void, arr1: any[], ...args: any[]): any[] { | |||
| export function __TS__ArrayConcat(this: void, arr1: any[], ...args: any[]): any[] { | |||
There was a problem hiding this comment.
Out of scope for this PR, this should be considered in a separate PR.
| const superInfo = getOrUpdate(classSuperInfos, context, () => []); | ||
| superInfo.push({ className, extendedTypeNode }); | ||
|
|
||
| if (extendedType) { |
There was a problem hiding this comment.
Are you sure this can be removed? Why does this not break promises construction?
There was a problem hiding this comment.
The check for lualib type has been moved to transformIdentifier. For a class extends, transformIdentifier is eventually called in createClassSetup.
src/transpilation/transpiler.ts
Outdated
| const relativeOutputPath = getEmitPathRelativeToOutDir(file, program); | ||
| export function getEmitPath(file: string | ProcessedFile, program: ts.Program): string { | ||
| const outDir = getEmitOutDir(program); | ||
| if (typeof file !== "string" && file.isRawFile) { |
| code: string; | ||
| sourceMap?: string; | ||
| sourceFiles?: ts.SourceFile[]; | ||
| isRawFile?: boolean; |
There was a problem hiding this comment.
This is for the json file. Before getEmitPath expects absolute paths and turns filenames into lua, and the json file name is not absolute. This allows treating the json file differently.
If you can think of a better way to handle this let me know.
| "lualibuser.lua", | ||
| ` | ||
| require("lualib_bundle") | ||
| local __TS__ArrayPush = require("lualib_bundle").__TS__ArrayPush |
There was a problem hiding this comment.
why is this optimized into one statement here, but not in the cases in the snapshot below?
8e8aa39 to
1132f16
Compare
|
Closing in favor of #1224 |
This implements lualib as modules (lualib source files and lualib_bundle are now modules), removes use of global variables.
lualibCompilationfor compiling lualib.export defaultorexport =As this mode is meant to be "internal", these restrictions are currently not enforced (no checking or diagnostics).
lualib_modules_info.json.Additional details
Each lualib module compilations's output is such that it declares local variables that correspond to the module's exports, potentially wrapping module statements in a
doblock if nessecary to avoid leaking variables out of scope. See sourceFile.ts for more info.This allows lualib modules to have non-exported members, i.e. be written like a normal module.
The result can be directly inlined for
lualibImport: "inline", or for assemblinglualib_bundle.Possible future changes
const func = Object.assignorconst foo = consoleworks.EDIT: reflect latest commits.
Thanks to @Zamiell for testing these changes in an existing project.