@thigasdevelopment/luam 0.10.2 → 0.10.3

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.
Files changed (2) hide show
  1. package/luam.mjs +54 -4
  2. package/package.json +1 -1
package/luam.mjs CHANGED
@@ -6050,7 +6050,7 @@ import { tmpdir } from "node:os";
6050
6050
  import { join as join2 } from "node:path";
6051
6051
 
6052
6052
  // src/cli/version.ts
6053
- var VERSION = true ? "0.10.2" : "0.0.0-dev";
6053
+ var VERSION = true ? "0.10.3" : "0.0.0-dev";
6054
6054
  var PROGRAM_NAME = "luam";
6055
6055
  var PROGRAM_DESCRIPTION = "luam \u2014 the Luam compiler for Multi Theft Auto resources.";
6056
6056
 
@@ -9425,7 +9425,7 @@ var MTA_OOP_1 = [
9425
9425
  ),
9426
9426
  oopClass(
9427
9427
  "Connection",
9428
- "Element",
9428
+ null,
9429
9429
  [
9430
9430
  oopMethod("exec", "server", "dbExec", fn([STRING, ANY], BOOLEAN, 1, true)),
9431
9431
  oopMethod("prepareString", "server", "dbPrepareString", fn([STRING, ANY], STRING, 1, true)),
@@ -11098,6 +11098,55 @@ function mtaMember(className, member) {
11098
11098
  return mtaClassRegistry().lookupMember(className, member);
11099
11099
  }
11100
11100
 
11101
+ // ../compiler/src/checker/shape-hint.ts
11102
+ function matchesDiscriminants(source, candidate) {
11103
+ for (const [name, member] of candidate.members) {
11104
+ const written = source.members.get(name);
11105
+ if (!isLiteralType(member) || written === void 0) {
11106
+ continue;
11107
+ }
11108
+ if (!isAssignable(written, member)) {
11109
+ return false;
11110
+ }
11111
+ }
11112
+ return true;
11113
+ }
11114
+ function chooseCandidate(source, candidates) {
11115
+ const [only] = candidates;
11116
+ if (candidates.length === 1 && only !== void 0) {
11117
+ return only;
11118
+ }
11119
+ const matching = candidates.filter((candidate) => matchesDiscriminants(source, candidate));
11120
+ const [best] = matching;
11121
+ return matching.length === 1 && best !== void 0 ? best : null;
11122
+ }
11123
+ function missingKeys(source, target) {
11124
+ const missing = [];
11125
+ for (const [name, member] of target.members) {
11126
+ if (member.kind !== "optional" && !source.members.has(name)) {
11127
+ missing.push(`"${name}"`);
11128
+ }
11129
+ }
11130
+ return missing;
11131
+ }
11132
+ function missingKeyHint(source, target) {
11133
+ if (source.kind !== "record" || source.isLiteral !== true) {
11134
+ return "";
11135
+ }
11136
+ const options = target.kind === "union" ? target.options : [target];
11137
+ const candidates = options.filter((option) => option.kind === "record");
11138
+ const candidate = chooseCandidate(source, candidates);
11139
+ if (candidate === null) {
11140
+ return "";
11141
+ }
11142
+ const missing = missingKeys(source, candidate);
11143
+ if (missing.length === 0) {
11144
+ return "";
11145
+ }
11146
+ const label2 = missing.length === 1 ? `Key ${missing[0]} is` : `Keys ${missing.join(", ")} are`;
11147
+ return ` ${label2} missing from "${typeToString(candidate)}".`;
11148
+ }
11149
+
11101
11150
  // ../compiler/src/checker/type-intersection.ts
11102
11151
  function namedMembers(context, name) {
11103
11152
  if (context.declarations.lookupInterface(name) === null && context.declarations.lookupClass(name) === null) {
@@ -11382,7 +11431,8 @@ var CheckContext = class {
11382
11431
  }
11383
11432
  const received = isLiteralType(target) || target.kind === "union" ? source : widenLiteral(source);
11384
11433
  const message = `${subject} expects "${typeToString(target)}" but received "${typeToString(received)}".`;
11385
- this.report("check-type-mismatch", `${message}${nilHint(source, target, this.mode)}`, position2);
11434
+ const hint = `${nilHint(source, target, this.mode)}${missingKeyHint(source, target)}`;
11435
+ this.report("check-type-mismatch", `${message}${hint}`, position2);
11386
11436
  }
11387
11437
  declareProject(project) {
11388
11438
  for (const declaration of project.globals) {
@@ -12120,7 +12170,7 @@ var ELEMENT_TYPES = [
12120
12170
  { name: "Browser", parent: "Element" },
12121
12171
  { name: "Camera", parent: "Element" },
12122
12172
  { name: "ColShape", parent: "Element" },
12123
- { name: "Connection", parent: "Element" },
12173
+ { name: "Connection", parent: null },
12124
12174
  { name: "DxFont", parent: null },
12125
12175
  { name: "DxRenderTarget", parent: null },
12126
12176
  { name: "DxScreenSource", parent: null },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thigasdevelopment/luam",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "description": "The Luam compiler for Multi Theft Auto resources.",
5
5
  "keywords": [
6
6
  "mta",