Skip to content

Commit 8711521

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents d95d056 + 86cc1b9 commit 8711521

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+788
-340
lines changed

.devcontainer/devcontainer.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "TypeScriptToLua",
3+
"image": "mcr.microsoft.com/vscode/devcontainers/javascript-node:14",
4+
"settings": {
5+
"terminal.integrated.shell.linux": "/bin/bash"
6+
},
7+
"extensions": [
8+
"ark120202.vscode-typescript-to-lua",
9+
"dbaeumer.vscode-eslint",
10+
"editorconfig.editorconfig",
11+
"esbenp.prettier-vscode"
12+
],
13+
"postCreateCommand": "npm ci"
14+
}

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* text eol=lf
1+
* text=auto eol=lf

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ jobs:
6161
node-version: 12.13.1
6262
# NPM
6363
- name: NPM master
64-
# TODO Lua types is only added manually to test the benchmark PR this can be removed again once the PR is merged
65-
run: npm ci && npm run build && npm install -D lua-types
64+
run: npm ci && npm run build
6665
working-directory: master
6766
- name: NPM commit
6867
run: npm ci && npm run build
@@ -112,7 +111,12 @@ jobs:
112111
const benchmarkInfoLua = JSON.parse(core.getInput('benchmark-info-lua', { required: true }));
113112
const benchmarkInfoJIT = JSON.parse(core.getInput('benchmark-info-jit', { required: true }));
114113
115-
const summary = `### Lua5.3\n${benchmarkInfoLua.summary}\n### LuaJIT\n${benchmarkInfoJIT.summary}`;
114+
const zlib = require('zlib');
115+
const buffer = Buffer.from(core.getInput('benchmark-info-lua', { required: true }));
116+
const compressed = zlib.deflateSync(buffer);
117+
118+
const summary = `[Open visualizer](https://typescripttolua.github.io/benchviz?d=${compressed.toString('base64')})\n`
119+
+ `### Lua5.3\n${benchmarkInfoLua.summary}\n### LuaJIT\n${benchmarkInfoJIT.summary}`;
116120
117121
const text = `### Lua5.3\n${benchmarkInfoLua.text}\n### LuaJIT\n${benchmarkInfoJIT.text}`;
118122

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 0.36.0
4+
5+
- Upgraded to TypeScript 4.0.
6+
- Added support for `parseInt` and `parseFloat`.
7+
- Added support for `yield*` [for generator functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield*).
8+
- Added support for [method, property and accessor decorators](https://www.typescriptlang.org/docs/handbook/decorators.html).
9+
- Shebangs at the top of a .ts file will now be preserved.
10+
- Fixed an issue causing declarations referencing their own identifier to cause a nil reference error.
11+
312
## 0.35.0
413

514
- In preparation for some new features, some public APIs have been changed:

benchmark/src/run.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ function benchmark(): void {
2727
oldBenchmarkResults = json.decode(oldBenchmarkData) as BenchmarkResult[];
2828
}
2929

30-
// Compare results
31-
const comparisonInfo = compareBenchmarks(oldBenchmarkResults, newBenchmarkResults);
32-
3330
// Output comparison info
34-
outputBenchmarkData(comparisonInfo, newBenchmarkResults);
31+
outputBenchmarkData(oldBenchmarkResults, newBenchmarkResults);
3532
}
3633
benchmark();
3734

@@ -44,12 +41,14 @@ function compareBenchmarks(oldResults: BenchmarkResult[], newResults: BenchmarkR
4441
return { summary: memoryComparisonInfo.summary, text: memoryComparisonInfo.text };
4542
}
4643

47-
function outputBenchmarkData(comparisonInfo: { summary: string; text: string }, newResults: BenchmarkResult[]): void {
44+
function outputBenchmarkData(oldResults: BenchmarkResult[], newResults: BenchmarkResult[]): void {
4845
if (!arg[2]) {
4946
// Output to stdout as json by default, this is used by the CI to retrieve the info
50-
print(json.encode(comparisonInfo));
47+
print(json.encode({ old: oldResults, new: newResults }));
5148
} else {
5249
// Output to file as markdown if arg[2] is set, this is useful for local development
50+
// Compare results
51+
const comparisonInfo = compareBenchmarks(oldResults, newResults);
5352
const markdownDataFile = io.open(arg[2], "w+")[0]!;
5453
markdownDataFile.write(comparisonInfo.summary + comparisonInfo.text);
5554
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typescript-to-lua",
3-
"version": "0.35.0",
3+
"version": "0.36.0",
44
"description": "A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!",
55
"repository": "https://github.com/TypeScriptToLua/TypeScriptToLua",
66
"license": "MIT",

src/CompilerOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface TransformerImport {
2121
export interface LuaPluginImport {
2222
name: string;
2323
import?: string;
24+
[option: string]: any;
2425
}
2526

2627
export type CompilerOptions = OmitIndexSignature<ts.CompilerOptions> & {

src/LuaAST.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
// because we don't create the AST from text
66

77
import * as ts from "typescript";
8+
import { LuaLibFeature } from "./transformation/utils/lualib";
89
import { castArray } from "./utils";
910

1011
export enum SyntaxKind {
12+
File,
1113
Block,
1214

1315
// Statements
@@ -186,6 +188,30 @@ export function getOriginalPos(node: Node): TextRange {
186188
return { line: node.line, column: node.column };
187189
}
188190

191+
export interface File extends Node {
192+
kind: SyntaxKind.File;
193+
statements: Statement[];
194+
luaLibFeatures: Set<LuaLibFeature>;
195+
trivia: string;
196+
}
197+
198+
export function isFile(node: Node): node is File {
199+
return node.kind === SyntaxKind.File;
200+
}
201+
202+
export function createFile(
203+
statements: Statement[],
204+
luaLibFeatures: Set<LuaLibFeature>,
205+
trivia: string,
206+
tsOriginal?: ts.Node
207+
): File {
208+
const file = createNode(SyntaxKind.File, tsOriginal) as File;
209+
file.statements = statements;
210+
file.luaLibFeatures = luaLibFeatures;
211+
file.trivia = trivia;
212+
return file;
213+
}
214+
189215
export interface Block extends Node {
190216
kind: SyntaxKind.Block;
191217
statements: Statement[];

src/LuaLib.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ export enum LuaLibFeature {
2828
ArraySetLength = "ArraySetLength",
2929
Class = "Class",
3030
ClassExtends = "ClassExtends",
31+
CloneDescriptor = "CloneDescriptor",
3132
Decorate = "Decorate",
32-
Descriptors = "Descriptors",
33+
DecorateParam = "DecorateParam",
34+
Delete = "Delete",
35+
DelegatedYield = "DelegatedYield",
3336
Error = "Error",
3437
FunctionBind = "FunctionBind",
3538
Generator = "Generator",
@@ -44,14 +47,18 @@ export enum LuaLibFeature {
4447
NumberIsNaN = "NumberIsNaN",
4548
NumberToString = "NumberToString",
4649
ObjectAssign = "ObjectAssign",
50+
ObjectDefineProperty = "ObjectDefineProperty",
4751
ObjectEntries = "ObjectEntries",
4852
ObjectFromEntries = "ObjectFromEntries",
53+
ObjectGetOwnPropertyDescriptor = "ObjectGetOwnPropertyDescriptor",
54+
ObjectGetOwnPropertyDescriptors = "ObjectGetOwnPropertyDescriptors",
4955
ObjectKeys = "ObjectKeys",
5056
ObjectRest = "ObjectRest",
5157
ObjectValues = "ObjectValues",
5258
ParseFloat = "ParseFloat",
5359
ParseInt = "ParseInt",
5460
Set = "Set",
61+
SetDescriptor = "SetDescriptor",
5562
WeakMap = "WeakMap",
5663
WeakSet = "WeakSet",
5764
SourceMapTraceBack = "SourceMapTraceBack",
@@ -81,11 +88,14 @@ export enum LuaLibFeature {
8188
const luaLibDependencies: Partial<Record<LuaLibFeature, LuaLibFeature[]>> = {
8289
ArrayFlat: [LuaLibFeature.ArrayConcat],
8390
ArrayFlatMap: [LuaLibFeature.ArrayConcat],
91+
Decorate: [LuaLibFeature.CloneDescriptor],
92+
Delete: [LuaLibFeature.ObjectGetOwnPropertyDescriptors],
8493
Error: [LuaLibFeature.New, LuaLibFeature.Class],
8594
FunctionBind: [LuaLibFeature.Unpack],
8695
Generator: [LuaLibFeature.Symbol],
8796
InstanceOf: [LuaLibFeature.Symbol],
8897
Iterator: [LuaLibFeature.Symbol],
98+
ObjectDefineProperty: [LuaLibFeature.CloneDescriptor, LuaLibFeature.SetDescriptor],
8999
ObjectFromEntries: [LuaLibFeature.Iterator, LuaLibFeature.Symbol],
90100
Map: [LuaLibFeature.InstanceOf, LuaLibFeature.Iterator, LuaLibFeature.Symbol, LuaLibFeature.Class],
91101
Set: [LuaLibFeature.InstanceOf, LuaLibFeature.Iterator, LuaLibFeature.Symbol, LuaLibFeature.Class],

0 commit comments

Comments
 (0)