Skip to content

Commit 551f04d

Browse files
authored
Merge branch 'master' into patch-1
2 parents 1003d1c + e0e56fe commit 551f04d

File tree

200 files changed

+7429
-5922
lines changed

Some content is hidden

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

200 files changed

+7429
-5922
lines changed

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
/test/cli/errors
44
/test/cli/watch
55
/test/transpile/directories
6-
/test/transpile/module-resolution/*/node_modules
6+
/test/transpile/module-resolution/**/node_modules
7+
/test/transpile/module-resolution/**/dist
78
/test/transpile/outFile

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ jobs:
4747
steps:
4848
- name: Lua Install
4949
run: sudo apt-get install lua5.3 luajit
50+
- name: Add Brew to Path (Required since Nov 2022)
51+
run: echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
5052
- name: Glow Install
5153
run: brew install glow
5254
# Checkout master & commit

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
node_modules
22
/dist
33
/coverage
4+
/test/transpile/module-resolution/**/dist
5+
/test/transpile/module-resolution/**/tsconfig.tsbuildinfo
46

57
yarn.lock
68
.vscode

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
/coverage
33
/test/translation/transformation/characterEscapeSequence.ts
44
/benchmark/dist
5+
/test/transpile/module-resolution/**/node_modules
6+
/test/transpile/module-resolution/**/dist

CHANGELOG.md

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

3+
## 1.21.0
4+
5+
- Added support for `continue` for Lua 5.0, 5.1 and universal targets.
6+
- Added support for the new `/** @customName myCustomName **/` decorator, which allows renaming of variables and identifiers.
7+
- This is useful to get around names that are reserved keywords in TypeScript, but are used in Lua API
8+
- Fixed a bug that caused super calls in static methods to throw an error
9+
10+
## 1.20.0
11+
12+
- Added support for `Number.parseInt` and `Number.parseFloat` (mapped to same implementation as global `parseInt` and `parseFloat`)
13+
- Added implementation for multiple `Number` constants like `Number.EPSILON`
14+
- Added support for `Array.at`
15+
- Fixed a bug when throwing an error object in a Lua environment without `debug` module
16+
- Fixed a bug causing files not to be found when returning an absolute path from a `moduleResolution` plugin
17+
18+
## 1.19.0
19+
20+
- Added support for the new TypeScript 5.2 `using` keyword for explicit resource management. See the [TypeScript release notes](https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/#using-declarations-and-explicit-resource-management) for more information.
21+
- Added support for the newly introduced 'copying array methods' `toReversed`, `toSorted`, `toSpliced` and `with`. These were also introduced in TypeScript 5.2, see [their release notes](https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/#copying-array-methods) for more information.
22+
23+
## 1.18.0
24+
25+
- Upgraded TypeScript to 5.2.2
26+
- The `noResolvePaths` option now accepts glob paths (for example, 'mydir/hello\*' to not resolve any files in mydir starting with hello).
27+
- This also allows disabling module resolution completely by providing a '\*\*' pattern in your tsconfig.json `noResolvePaths`.
28+
29+
## 1.17.0
30+
31+
- Added the `moduleResolution` plugin, allowing you to provide custom module resolution logic. See [the docs](https://typescripttolua.github.io/docs/api/plugins#moduleresolution) for more info.
32+
- Added `isEmpty` to `LuaTable`, `LuaMap` and `LuaSet` (and their read-only counterparts). This simply to `next(tbl) == nil`, allowing for a simple check to see if a table is empty or not.
33+
- Fixed a bug with synthetic nodes (e.g. created by custom TypeScript transformers) throwing an exception.
34+
- Fixed unnecessary extra unpacking of tables
35+
- Fixed some bugs with new decorators
36+
37+
## 1.16.0
38+
39+
- Upgraded TypeScript to 5.1.3.
40+
- Added support for [TypeScript 5.0 decorators](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#decorators).
41+
- Old-style decorators will still work as long as you have `experimentalDecorators` configured, otherwise the new standard is used.
42+
- Added support for [class static initialization blocks](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Static_initialization_blocks).
43+
- Fixed a bug causing the `tstl` object in tsconfig.json not to be properly extended when extending a tsconfig from node_modules.
44+
45+
## 1.15.0
46+
47+
- Using `extends` in tsconfig.json now also correctly merges settings in the `tstl` block (shallow merge).
48+
- Now avoiding assigning default parameter values if the default value is `nil` (`null` or `undefined`).
49+
- Fixed a bug where indexing a `LuaMultiReturn` value with [0] would still return everything.
50+
- Fixed a bug with nested namespaces causing unexpected nil indexing errors.
51+
52+
## 1.14.0
53+
54+
- **[Breaking]** Upgraded TypeScript to 5.0.
55+
- Added support for `Number.toFixed`.
56+
- Added support for spread expressions with `LuaPairsIterable` and `LuaPairsKeysIterable`.
57+
- Fixed a bug breaking module resolution when using a custom file extension.
58+
- Fixed various exceptions that could happen when trying to translate invalid TS.
59+
60+
## 1.13.0
61+
62+
- Fixed alternate file extensions (other than .lua, if configured) breaking module resolution and emitted require statements.
63+
- Added experimental support for `"luaLibImport": "require-minimal"` configuration option. This will output a lualib bundle containing only the lualib functions used by your code. This might not work if you are including external tstl-generated Lua, for example from a npm package.
64+
- Added support for the "exports" field in package.json.
65+
- Fixed some exceptions resulting from invalid language-extensions use.
66+
- Fixed an exception when using compound assignment (like `+=`) with array length.
67+
68+
## 1.12.0
69+
70+
- Reworked how tstl detects and rewrites `require` statements during dependency resolution. This should reduce the amount of false-positive matches of require statements: require statements in string literals or comments should no longer be detected by tstl. This means require statements in string literals or comments can survive the transpiler without causing a 'could not resolve lua sources' error or getting rewritten into nonsense.
71+
- Now using `math.mod` for Lua 5.0 modulo operations.
72+
73+
## 1.11.0
74+
75+
- **[Breaking]** Upgraded TypeScript to 4.9.
76+
- `--tstlVerbose` now prints more resolver output when failing to resolve Lua sources.
77+
- Fixed a bug breaking default exported classes with unicode names
78+
- Relaxed conditions for the always-true warning to false positives.
79+
380
## 1.10.0
481

582
- **[Breaking]** Upgraded TypeScript to 4.8.

jest.config.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ module.exports = {
1515
testEnvironment: "node",
1616
testRunner: "jest-circus/runner",
1717
preset: "ts-jest",
18-
globals: {
19-
"ts-jest": {
20-
tsconfig: "<rootDir>/test/tsconfig.json",
21-
diagnostics: { warnOnly: !isCI },
22-
},
18+
transform: {
19+
"^.+\\.ts?$": [
20+
"ts-jest",
21+
{
22+
tsconfig: "<rootDir>/test/tsconfig.json",
23+
diagnostics: { warnOnly: !isCI },
24+
},
25+
],
2326
},
2427
};

language-extensions/index.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,20 @@ declare type LuaTableDelete<TTable extends AnyTable, TKey extends AnyNotNil> = (
562562
declare type LuaTableDeleteMethod<TKey extends AnyNotNil> = ((key: TKey) => boolean) &
563563
LuaExtension<"TableDeleteMethod">;
564564

565+
/**
566+
* Calls to functions with this type are translated to `next(myTable) == nil`.
567+
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
568+
*
569+
* @param TTable The type to access as a Lua table.
570+
*/
571+
declare type LuaTableIsEmpty<TTable extends AnyTable> = ((table: TTable) => boolean) & LuaExtension<"TableIsEmpty">;
572+
573+
/**
574+
* Calls to methods with this type are translated to `next(myTable) == nil`, where `table` is the object with the method.
575+
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
576+
*/
577+
declare type LuaTableIsEmptyMethod = (() => boolean) & LuaExtension<"TableIsEmptyMethod">;
578+
565579
/**
566580
* A convenience type for working directly with a Lua table.
567581
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
@@ -575,6 +589,7 @@ declare interface LuaTable<TKey extends AnyNotNil = AnyNotNil, TValue = any> ext
575589
set: LuaTableSetMethod<TKey, TValue>;
576590
has: LuaTableHasMethod<TKey>;
577591
delete: LuaTableDeleteMethod<TKey>;
592+
isEmpty: LuaTableIsEmptyMethod;
578593
}
579594

580595
/**
@@ -612,6 +627,7 @@ declare interface LuaMap<K extends AnyNotNil = AnyNotNil, V = any> extends LuaPa
612627
set: LuaTableSetMethod<K, V>;
613628
has: LuaTableHasMethod<K>;
614629
delete: LuaTableDeleteMethod<K>;
630+
isEmpty: LuaTableIsEmptyMethod;
615631
}
616632

617633
/**
@@ -633,6 +649,7 @@ declare const LuaMap: (new <K extends AnyNotNil = AnyNotNil, V = any>() => LuaMa
633649
declare interface ReadonlyLuaMap<K extends AnyNotNil = AnyNotNil, V = any> extends LuaPairsIterable<K, V> {
634650
get: LuaTableGetMethod<K, V | undefined>;
635651
has: LuaTableHasMethod<K>;
652+
isEmpty: LuaTableIsEmptyMethod;
636653
}
637654

638655
/**
@@ -645,6 +662,7 @@ declare interface LuaSet<T extends AnyNotNil = AnyNotNil> extends LuaPairsKeyIte
645662
add: LuaTableAddKeyMethod<T>;
646663
has: LuaTableHasMethod<T>;
647664
delete: LuaTableDeleteMethod<T>;
665+
isEmpty: LuaTableIsEmptyMethod;
648666
}
649667

650668
/**
@@ -662,6 +680,7 @@ declare const LuaSet: (new <T extends AnyNotNil = AnyNotNil>() => LuaSet<T>) & L
662680
*/
663681
declare interface ReadonlyLuaSet<T extends AnyNotNil = AnyNotNil> extends LuaPairsKeyIterable<T> {
664682
has: LuaTableHasMethod<T>;
683+
isEmpty: LuaTableIsEmptyMethod;
665684
}
666685

667686
interface ObjectConstructor {

language-extensions/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/language-extensions",
3-
"version": "1.0.0",
3+
"version": "1.19.0",
44
"description": "Language extensions used by typescript-to-lua",
55
"repository": "https://github.com/TypeScriptToLua/TypeScriptToLua",
66
"homepage": "https://typescripttolua.github.io/",

0 commit comments

Comments
 (0)