typescript-to-lua 1.24.1 → 1.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/LuaLib.d.ts CHANGED
@@ -55,6 +55,7 @@ export declare enum LuaLibFeature {
55
55
  Iterator = "Iterator",
56
56
  LuaIteratorSpread = "LuaIteratorSpread",
57
57
  Map = "Map",
58
+ MapGroupBy = "MapGroupBy",
58
59
  Match = "Match",
59
60
  MathAtan2 = "MathAtan2",
60
61
  MathModf = "MathModf",
@@ -74,6 +75,7 @@ export declare enum LuaLibFeature {
74
75
  ObjectFromEntries = "ObjectFromEntries",
75
76
  ObjectGetOwnPropertyDescriptor = "ObjectGetOwnPropertyDescriptor",
76
77
  ObjectGetOwnPropertyDescriptors = "ObjectGetOwnPropertyDescriptors",
78
+ ObjectGroupBy = "ObjectGroupBy",
77
79
  ObjectKeys = "ObjectKeys",
78
80
  ObjectRest = "ObjectRest",
79
81
  ObjectValues = "ObjectValues",
package/dist/LuaLib.js CHANGED
@@ -60,6 +60,7 @@ var LuaLibFeature;
60
60
  LuaLibFeature["Iterator"] = "Iterator";
61
61
  LuaLibFeature["LuaIteratorSpread"] = "LuaIteratorSpread";
62
62
  LuaLibFeature["Map"] = "Map";
63
+ LuaLibFeature["MapGroupBy"] = "MapGroupBy";
63
64
  LuaLibFeature["Match"] = "Match";
64
65
  LuaLibFeature["MathAtan2"] = "MathAtan2";
65
66
  LuaLibFeature["MathModf"] = "MathModf";
@@ -79,6 +80,7 @@ var LuaLibFeature;
79
80
  LuaLibFeature["ObjectFromEntries"] = "ObjectFromEntries";
80
81
  LuaLibFeature["ObjectGetOwnPropertyDescriptor"] = "ObjectGetOwnPropertyDescriptor";
81
82
  LuaLibFeature["ObjectGetOwnPropertyDescriptors"] = "ObjectGetOwnPropertyDescriptors";
83
+ LuaLibFeature["ObjectGroupBy"] = "ObjectGroupBy";
82
84
  LuaLibFeature["ObjectKeys"] = "ObjectKeys";
83
85
  LuaLibFeature["ObjectRest"] = "ObjectRest";
84
86
  LuaLibFeature["ObjectValues"] = "ObjectValues";
@@ -97,7 +97,7 @@ function createConfigFileUpdater(optionsToExtend) {
97
97
  if (!configFile || !configFilePath)
98
98
  return [];
99
99
  if (!configFileMap.has(configFile)) {
100
- const parsedConfigFile = (0, parse_1.updateParsedConfigFile)(ts.parseJsonSourceFileConfigFileContent(configFile, ts.sys, path.dirname(configFilePath), optionsToExtend, configFilePath));
100
+ const parsedConfigFile = parseConfigFileWithSystem(configFilePath, optionsToExtend, ts.sys);
101
101
  configFileMap.set(configFile, parsedConfigFile);
102
102
  }
103
103
  const parsedConfigFile = configFileMap.get(configFile);
@@ -1,9 +1,10 @@
1
1
  local __TS__AsyncAwaiter, __TS__Await
2
2
  do
3
- local cocreate = coroutine.create
4
- local coresume = coroutine.resume
5
- local costatus = coroutine.status
6
- local coyield = coroutine.yield
3
+ local ____coroutine = _G.coroutine or ({})
4
+ local cocreate = ____coroutine.create
5
+ local coresume = ____coroutine.resume
6
+ local costatus = ____coroutine.status
7
+ local coyield = ____coroutine.yield
7
8
  function __TS__AsyncAwaiter(generator)
8
9
  return __TS__New(
9
10
  __TS__Promise,
@@ -0,0 +1,15 @@
1
+ local function __TS__MapGroupBy(items, keySelector)
2
+ local result = __TS__New(Map)
3
+ local i = 0
4
+ for ____, item in __TS__Iterator(items) do
5
+ local key = keySelector(nil, item, i)
6
+ if result:has(key) then
7
+ local ____temp_0 = result:get(key)
8
+ ____temp_0[table.getn(____temp_0) + 1] = item
9
+ else
10
+ result:set(key, {item})
11
+ end
12
+ i = i + 1
13
+ end
14
+ return result
15
+ end
@@ -0,0 +1,15 @@
1
+ local function __TS__ObjectGroupBy(items, keySelector)
2
+ local result = {}
3
+ local i = 0
4
+ for ____, item in __TS__Iterator(items) do
5
+ local key = keySelector(nil, item, i)
6
+ if result[key] ~= nil then
7
+ local ____result_key_0 = result[key]
8
+ ____result_key_0[table.getn(____result_key_0) + 1] = item
9
+ else
10
+ result[key] = {item}
11
+ end
12
+ i = i + 1
13
+ end
14
+ return result
15
+ end
@@ -777,10 +777,11 @@ end
777
777
 
778
778
  local __TS__AsyncAwaiter, __TS__Await
779
779
  do
780
- local cocreate = coroutine.create
781
- local coresume = coroutine.resume
782
- local costatus = coroutine.status
783
- local coyield = coroutine.yield
780
+ local ____coroutine = _G.coroutine or ({})
781
+ local cocreate = ____coroutine.create
782
+ local coresume = ____coroutine.resume
783
+ local costatus = ____coroutine.status
784
+ local coyield = ____coroutine.yield
784
785
  function __TS__AsyncAwaiter(generator)
785
786
  return __TS__New(
786
787
  __TS__Promise,
@@ -1446,6 +1447,22 @@ do
1446
1447
  Map[Symbol.species] = Map
1447
1448
  end
1448
1449
 
1450
+ local function __TS__MapGroupBy(items, keySelector)
1451
+ local result = __TS__New(Map)
1452
+ local i = 0
1453
+ for ____, item in __TS__Iterator(items) do
1454
+ local key = keySelector(nil, item, i)
1455
+ if result:has(key) then
1456
+ local ____temp_0 = result:get(key)
1457
+ ____temp_0[table.getn(____temp_0) + 1] = item
1458
+ else
1459
+ result:set(key, {item})
1460
+ end
1461
+ i = i + 1
1462
+ end
1463
+ return result
1464
+ end
1465
+
1449
1466
  local function __TS__StringSlice(self, start, ____end)
1450
1467
  if start == nil or start ~= start then
1451
1468
  start = 0
@@ -1740,6 +1757,22 @@ local function __TS__ObjectFromEntries(entries)
1740
1757
  return obj
1741
1758
  end
1742
1759
 
1760
+ local function __TS__ObjectGroupBy(items, keySelector)
1761
+ local result = {}
1762
+ local i = 0
1763
+ for ____, item in __TS__Iterator(items) do
1764
+ local key = keySelector(nil, item, i)
1765
+ if result[key] ~= nil then
1766
+ local ____result_key_0 = result[key]
1767
+ ____result_key_0[table.getn(____result_key_0) + 1] = item
1768
+ else
1769
+ result[key] = {item}
1770
+ end
1771
+ i = i + 1
1772
+ end
1773
+ return result
1774
+ end
1775
+
1743
1776
  local function __TS__ObjectKeys(obj)
1744
1777
  local result = {}
1745
1778
  local len = 0
@@ -2623,6 +2656,7 @@ return {
2623
2656
  __TS__Iterator = __TS__Iterator,
2624
2657
  __TS__LuaIteratorSpread = __TS__LuaIteratorSpread,
2625
2658
  Map = Map,
2659
+ __TS__MapGroupBy = __TS__MapGroupBy,
2626
2660
  __TS__Match = __TS__Match,
2627
2661
  __TS__MathAtan2 = __TS__MathAtan2,
2628
2662
  __TS__MathModf = __TS__MathModf,
@@ -2642,6 +2676,7 @@ return {
2642
2676
  __TS__ObjectFromEntries = __TS__ObjectFromEntries,
2643
2677
  __TS__ObjectGetOwnPropertyDescriptor = __TS__ObjectGetOwnPropertyDescriptor,
2644
2678
  __TS__ObjectGetOwnPropertyDescriptors = __TS__ObjectGetOwnPropertyDescriptors,
2679
+ __TS__ObjectGroupBy = __TS__ObjectGroupBy,
2645
2680
  __TS__ObjectKeys = __TS__ObjectKeys,
2646
2681
  __TS__ObjectRest = __TS__ObjectRest,
2647
2682
  __TS__ObjectValues = __TS__ObjectValues,
@@ -351,6 +351,16 @@
351
351
  "Iterator"
352
352
  ]
353
353
  },
354
+ "MapGroupBy": {
355
+ "exports": [
356
+ "__TS__MapGroupBy"
357
+ ],
358
+ "dependencies": [
359
+ "Map",
360
+ "New",
361
+ "Iterator"
362
+ ]
363
+ },
354
364
  "Match": {
355
365
  "exports": [
356
366
  "__TS__Match"
@@ -471,6 +481,14 @@
471
481
  "__TS__ObjectGetOwnPropertyDescriptors"
472
482
  ]
473
483
  },
484
+ "ObjectGroupBy": {
485
+ "exports": [
486
+ "__TS__ObjectGroupBy"
487
+ ],
488
+ "dependencies": [
489
+ "Iterator"
490
+ ]
491
+ },
474
492
  "ObjectKeys": {
475
493
  "exports": [
476
494
  "__TS__ObjectKeys"
@@ -1,9 +1,10 @@
1
1
  local __TS__AsyncAwaiter, __TS__Await
2
2
  do
3
- local cocreate = coroutine.create
4
- local coresume = coroutine.resume
5
- local costatus = coroutine.status
6
- local coyield = coroutine.yield
3
+ local ____coroutine = _G.coroutine or ({})
4
+ local cocreate = ____coroutine.create
5
+ local coresume = ____coroutine.resume
6
+ local costatus = ____coroutine.status
7
+ local coyield = ____coroutine.yield
7
8
  function __TS__AsyncAwaiter(generator)
8
9
  return __TS__New(
9
10
  __TS__Promise,
@@ -0,0 +1,15 @@
1
+ local function __TS__MapGroupBy(items, keySelector)
2
+ local result = __TS__New(Map)
3
+ local i = 0
4
+ for ____, item in __TS__Iterator(items) do
5
+ local key = keySelector(nil, item, i)
6
+ if result:has(key) then
7
+ local ____temp_0 = result:get(key)
8
+ ____temp_0[#____temp_0 + 1] = item
9
+ else
10
+ result:set(key, {item})
11
+ end
12
+ i = i + 1
13
+ end
14
+ return result
15
+ end
@@ -0,0 +1,15 @@
1
+ local function __TS__ObjectGroupBy(items, keySelector)
2
+ local result = {}
3
+ local i = 0
4
+ for ____, item in __TS__Iterator(items) do
5
+ local key = keySelector(nil, item, i)
6
+ if result[key] ~= nil then
7
+ local ____result_key_0 = result[key]
8
+ ____result_key_0[#____result_key_0 + 1] = item
9
+ else
10
+ result[key] = {item}
11
+ end
12
+ i = i + 1
13
+ end
14
+ return result
15
+ end
@@ -773,10 +773,11 @@ end
773
773
 
774
774
  local __TS__AsyncAwaiter, __TS__Await
775
775
  do
776
- local cocreate = coroutine.create
777
- local coresume = coroutine.resume
778
- local costatus = coroutine.status
779
- local coyield = coroutine.yield
776
+ local ____coroutine = _G.coroutine or ({})
777
+ local cocreate = ____coroutine.create
778
+ local coresume = ____coroutine.resume
779
+ local costatus = ____coroutine.status
780
+ local coyield = ____coroutine.yield
780
781
  function __TS__AsyncAwaiter(generator)
781
782
  return __TS__New(
782
783
  __TS__Promise,
@@ -1417,6 +1418,22 @@ do
1417
1418
  Map[Symbol.species] = Map
1418
1419
  end
1419
1420
 
1421
+ local function __TS__MapGroupBy(items, keySelector)
1422
+ local result = __TS__New(Map)
1423
+ local i = 0
1424
+ for ____, item in __TS__Iterator(items) do
1425
+ local key = keySelector(nil, item, i)
1426
+ if result:has(key) then
1427
+ local ____temp_0 = result:get(key)
1428
+ ____temp_0[#____temp_0 + 1] = item
1429
+ else
1430
+ result:set(key, {item})
1431
+ end
1432
+ i = i + 1
1433
+ end
1434
+ return result
1435
+ end
1436
+
1420
1437
  local __TS__Match = string.match
1421
1438
 
1422
1439
  local __TS__MathAtan2 = math.atan2 or math.atan
@@ -1671,6 +1688,22 @@ local function __TS__ObjectFromEntries(entries)
1671
1688
  return obj
1672
1689
  end
1673
1690
 
1691
+ local function __TS__ObjectGroupBy(items, keySelector)
1692
+ local result = {}
1693
+ local i = 0
1694
+ for ____, item in __TS__Iterator(items) do
1695
+ local key = keySelector(nil, item, i)
1696
+ if result[key] ~= nil then
1697
+ local ____result_key_0 = result[key]
1698
+ ____result_key_0[#____result_key_0 + 1] = item
1699
+ else
1700
+ result[key] = {item}
1701
+ end
1702
+ i = i + 1
1703
+ end
1704
+ return result
1705
+ end
1706
+
1674
1707
  local function __TS__ObjectKeys(obj)
1675
1708
  local result = {}
1676
1709
  local len = 0
@@ -2563,6 +2596,7 @@ return {
2563
2596
  __TS__Iterator = __TS__Iterator,
2564
2597
  __TS__LuaIteratorSpread = __TS__LuaIteratorSpread,
2565
2598
  Map = Map,
2599
+ __TS__MapGroupBy = __TS__MapGroupBy,
2566
2600
  __TS__Match = __TS__Match,
2567
2601
  __TS__MathAtan2 = __TS__MathAtan2,
2568
2602
  __TS__MathModf = __TS__MathModf,
@@ -2582,6 +2616,7 @@ return {
2582
2616
  __TS__ObjectFromEntries = __TS__ObjectFromEntries,
2583
2617
  __TS__ObjectGetOwnPropertyDescriptor = __TS__ObjectGetOwnPropertyDescriptor,
2584
2618
  __TS__ObjectGetOwnPropertyDescriptors = __TS__ObjectGetOwnPropertyDescriptors,
2619
+ __TS__ObjectGroupBy = __TS__ObjectGroupBy,
2585
2620
  __TS__ObjectKeys = __TS__ObjectKeys,
2586
2621
  __TS__ObjectRest = __TS__ObjectRest,
2587
2622
  __TS__ObjectValues = __TS__ObjectValues,
@@ -361,6 +361,16 @@
361
361
  "Iterator"
362
362
  ]
363
363
  },
364
+ "MapGroupBy": {
365
+ "exports": [
366
+ "__TS__MapGroupBy"
367
+ ],
368
+ "dependencies": [
369
+ "Map",
370
+ "New",
371
+ "Iterator"
372
+ ]
373
+ },
364
374
  "Match": {
365
375
  "exports": [
366
376
  "__TS__Match"
@@ -477,6 +487,14 @@
477
487
  "__TS__ObjectGetOwnPropertyDescriptors"
478
488
  ]
479
489
  },
490
+ "ObjectGroupBy": {
491
+ "exports": [
492
+ "__TS__ObjectGroupBy"
493
+ ],
494
+ "dependencies": [
495
+ "Iterator"
496
+ ]
497
+ },
480
498
  "ObjectKeys": {
481
499
  "exports": [
482
500
  "__TS__ObjectKeys"
@@ -20,6 +20,7 @@ const string_1 = require("./string");
20
20
  const symbol_1 = require("./symbol");
21
21
  const diagnostics_1 = require("../utils/diagnostics");
22
22
  const CompilerOptions_1 = require("../../CompilerOptions");
23
+ const map_1 = require("./map");
23
24
  function transformBuiltinPropertyAccessExpression(context, node) {
24
25
  const ownerType = context.checker.getTypeAtLocation(node.expression);
25
26
  if (ts.isIdentifier(node.expression) && (0, typescript_1.isStandardLibraryType)(context, ownerType, undefined)) {
@@ -81,6 +82,9 @@ function tryTransformBuiltinGlobalMethodCall(context, node, calledMethod) {
81
82
  case "Console":
82
83
  result = (0, console_1.transformConsoleCall)(context, node, calledMethod);
83
84
  break;
85
+ case "MapConstructor":
86
+ result = (0, map_1.transformMapConstructorCall)(context, node, calledMethod);
87
+ break;
84
88
  case "Math":
85
89
  result = (0, math_1.transformMathCall)(context, node, calledMethod);
86
90
  break;
@@ -0,0 +1,4 @@
1
+ import * as lua from "../../LuaAST";
2
+ import * as ts from "typescript";
3
+ import { TransformationContext } from "../context";
4
+ export declare function transformMapConstructorCall(context: TransformationContext, node: ts.CallExpression, calledMethod: ts.PropertyAccessExpression): lua.Expression | undefined;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformMapConstructorCall = void 0;
4
+ const diagnostics_1 = require("../utils/diagnostics");
5
+ const call_1 = require("../visitors/call");
6
+ const lualib_1 = require("../utils/lualib");
7
+ function transformMapConstructorCall(context, node, calledMethod) {
8
+ const args = (0, call_1.transformArguments)(context, node.arguments);
9
+ const methodName = calledMethod.name.text;
10
+ switch (methodName) {
11
+ case "groupBy":
12
+ return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.MapGroupBy, node, ...args);
13
+ default:
14
+ context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(calledMethod.name, "Map", methodName));
15
+ }
16
+ }
17
+ exports.transformMapConstructorCall = transformMapConstructorCall;
18
+ //# sourceMappingURL=map.js.map
@@ -21,6 +21,8 @@ function transformObjectConstructorCall(context, node, calledMethod) {
21
21
  return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ObjectGetOwnPropertyDescriptor, node, ...args);
22
22
  case "getOwnPropertyDescriptors":
23
23
  return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ObjectGetOwnPropertyDescriptors, node, ...args);
24
+ case "groupBy":
25
+ return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ObjectGroupBy, node, ...args);
24
26
  case "keys":
25
27
  return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ObjectKeys, node, ...args);
26
28
  case "values":
@@ -145,7 +145,8 @@ function getSourceDir(program) {
145
145
  if (rootDir && rootDir.length > 0) {
146
146
  return path.isAbsolute(rootDir) ? rootDir : path.resolve(getProjectRoot(program), rootDir);
147
147
  }
148
- return program.getCommonSourceDirectory();
148
+ // If no rootDir is given, source is relative to the project root
149
+ return getProjectRoot(program);
149
150
  }
150
151
  exports.getSourceDir = getSourceDir;
151
152
  function getEmitOutDir(program) {
package/dist/utils.d.ts CHANGED
@@ -2,8 +2,8 @@ import * as ts from "typescript";
2
2
  export declare function castArray<T>(value: T | T[]): T[];
3
3
  export declare function castArray<T>(value: T | readonly T[]): readonly T[];
4
4
  export declare const intersperse: <T>(values: readonly T[], separator: T) => T[];
5
- export declare const union: <T>(...values: Iterable<T>[]) => T[];
6
- export declare const intersection: <T>(first: readonly T[], ...rest: (readonly T[])[]) => T[];
5
+ export declare const union: <T>(...values: Array<Iterable<T>>) => T[];
6
+ export declare const intersection: <T>(first: readonly T[], ...rest: Array<readonly T[]>) => T[];
7
7
  type DiagnosticFactory = (...args: any) => Partial<ts.Diagnostic> & Pick<ts.Diagnostic, "messageText">;
8
8
  export declare const createDiagnosticFactoryWithCode: <T extends DiagnosticFactory>(code: number, create: T) => ((...args: Parameters<T>) => ts.Diagnostic) & {
9
9
  code: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typescript-to-lua",
3
- "version": "1.24.1",
3
+ "version": "1.25.1",
4
4
  "description": "A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!",
5
5
  "repository": "https://github.com/TypeScriptToLua/TypeScriptToLua",
6
6
  "homepage": "https://typescripttolua.github.io/",
@@ -42,7 +42,7 @@
42
42
  "node": ">=16.10.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "typescript": "5.3.3"
45
+ "typescript": "5.4.2"
46
46
  },
47
47
  "dependencies": {
48
48
  "@typescript-to-lua/language-extensions": "1.19.0",
@@ -72,6 +72,6 @@
72
72
  "prettier": "^2.8.4",
73
73
  "ts-jest": "^29.1.0",
74
74
  "ts-node": "^10.9.1",
75
- "typescript": "^5.3.3"
75
+ "typescript": "^5.4.2"
76
76
  }
77
77
  }