Skip to content

Typescript lualib#148

Merged
Perryvw merged 45 commits intomasterfrom
ts-lualib
Jul 22, 2018
Merged

Typescript lualib#148
Perryvw merged 45 commits intomasterfrom
ts-lualib

Conversation

@lolleko
Copy link
Copy Markdown
Member

@lolleko lolleko commented Jul 18, 2018

Open PR to reimplement runtime lualib features in typescript.

Fixes #80, Closes #134

TODO Compiler option for different import modes --luaLibImport

  • require require a bundled lualib in each file basically the same we currently have
  • inline inline the used lualib functions add the bottom of the file. (Probably default option)
  • noImport don't import or inline any runtime lib features

this will replaces the existing --dontRequireLuaLib

TODO Reimplement all lualib features in TS

  • ArrayEvery
  • ArrayFilter
  • ArrayForEach
  • ArrayIndexOf
  • ArrayMap
  • ArrayPush
  • ArraySlice
  • ArraySome
  • ArraySplice
  • InstanceOf
  • Map
  • Set
  • StringReplace
  • StringSplit
  • Ternary

build_lualib.ts Outdated
@@ -0,0 +1,25 @@
import concat = require("concat");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a dependency for this?

luaLibImport: {
choices: ["inline", "require", "none"],
default: "inline",
describe: "Specify Lua target version.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect description.

src/Compiler.ts Outdated
try {
const rootDir = options.rootDir;

// console.log(`Transpiling ${sourceFile.fileName}...`);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either uncomment or remove (I like it to see which file is causing errors).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably only print on error then.

src/Index.ts Outdated
@@ -0,0 +1,5 @@
#!/usr/bin/env node

import {compile} from "./Compiler";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file linted? Would expect { compile }

let result = "";
this.exportStack.pop().forEach(exp => result += this.makeExport(exp.name, exp.node, exp.dummy));
this.exportStack.pop().forEach(
exp => result += this.makeExport(exp.name, exp.node, exp.dummy));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random newline?

element => ((element as ts.BindingElement).name as ts.Identifier
).escapedText).join(",");
element =>
(this.transpileIdentifier((element as ts.BindingElement).name as ts.Identifier))).join(",");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transpileArrayBindingElement seems to fit here.

} else {
list[to] = undefined;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extraneous whiteline

@@ -0,0 +1,93 @@
// https://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
function __TS__ArraySplice<T>(list: T[], start: number, deleteCount: number, ...items: T[]): T[] {
// 1. 2.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would either write out the pseudo-code in the comments or just remove them. These numbers don't really add anything imo.

}
}

public add(value: TValue) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return type

@@ -204,20 +204,26 @@ export class LuaLibArrayTests {
@TestCase([], "test1")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should probably also be moved to test/unit/lualib

@Perryvw Perryvw merged commit fda1683 into master Jul 22, 2018
@lolleko lolleko changed the title WIP Typescript lualib Typescript lualib Jul 23, 2018
@Perryvw Perryvw deleted the ts-lualib branch July 27, 2018 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants