Skip to content

Use rescript@v10 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
]
},
"devDependencies": {
"rescript": "9.1.4",
"rescript": "^10.0.0-alpha.1",
"rescript-ava": "github:DZakh/rescript-ava#007d9f63e17310f73fabab1223eb75a0c9c36035"
}
}
19 changes: 11 additions & 8 deletions src/S.bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,30 +126,30 @@ function toReason(nestedLevelOpt, error) {
case /* UnexpectedValue */2 :
break;
case /* TupleSize */3 :
return "Expected Tuple with " + reason.expected.toString() + " items, received " + reason.received.toString();
return "Expected Tuple with " + reason.expected.toString() + " items, received " + reason.received.toString() + "";
case /* ExcessField */4 :
return "Encountered disallowed excess key \"" + reason._0 + "\" on an object. Use Deprecated to ignore a specific field, or S.Record.strip to ignore excess keys completely";
case /* InvalidUnion */5 :
var lineBreak = "\n" + " ".repeat((nestedLevel << 1));
var lineBreak = "\n" + " ".repeat((nestedLevel << 1)) + "";
var array = reason._0.map(function (error) {
var reason = toReason(nestedLevel + 1, error);
var nonEmptyPath = error.path;
var $$location = nonEmptyPath.length !== 0 ? "Failed at " + formatPath(nonEmptyPath) + ". " : "";
return "- " + $$location + reason;
return "- " + $$location + "" + reason + "";
});
var reasons = Array.from(new Set(array));
return "Invalid union with following errors" + lineBreak + reasons.join(lineBreak);
return "Invalid union with following errors" + lineBreak + "" + reasons.join(lineBreak) + "";

}
return "Expected " + reason.expected + ", received " + reason.received;
return "Expected " + reason.expected + ", received " + reason.received + "";
Comment on lines +141 to +144
Copy link
Owner Author

Choose a reason for hiding this comment

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

Started adding empty strings around values in template literal.

Choose a reason for hiding this comment

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

Can't seem to repro:

// tst.res
let template = (nestedLevel, reasons, foo) => {
  let lineBreak = `\n${" "->Js.String2.repeat(nestedLevel * 2)}`
  `Invalid union with following errors${lineBreak}${reasons->Js.Array2.joinWith(lineBreak)}`
}

gives

// Generated by ReScript, PLEASE EDIT WITH CARE
'use strict';


function template(nestedLevel, reasons, foo) {
  var lineBreak = "\n" + " ".repeat((nestedLevel << 1));
  return "Invalid union with following errors" + lineBreak + reasons.join(lineBreak);
}

exports.template = template;
/* No side effect */

Would you open an issue with a self-contained repro?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I've created an issue rescript-lang/rescript#5521

}

function toString(error) {
var match = error.operation;
var operation = match ? "parsing" : "serializing";
var reason = toReason(undefined, error);
var pathText = formatPath(error.path);
return "[ReScript Struct]" + " Failed " + operation + " at " + pathText + ". Reason: " + reason;
return "[ReScript Struct] Failed " + operation + " at " + pathText + ". Reason: " + reason + "";
Copy link
Owner Author

Choose a reason for hiding this comment

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

Here it joined to string values on compile-time, that's super cool!
([ReScript Struct] and Failed)

}

function classify(struct) {
Expand Down Expand Up @@ -260,6 +260,9 @@ function makeUnexpectedTypeError(input, struct) {
case /* JSSymbol */4 :
received = "Symbol";
break;
case /* JSBigInt */5 :
received = "BigInt";
break;

}
}
Expand Down Expand Up @@ -1272,7 +1275,7 @@ function min$1(struct, maybeMessage, thanValue) {
if (value >= thanValue) {
return ;
} else {
return Belt_Option.getWithDefault(maybeMessage, "Number must be greater than or equal to " + thanValue.toString());
return Belt_Option.getWithDefault(maybeMessage, "Number must be greater than or equal to " + thanValue.toString() + "");
}
};
return refine(struct, refiner, refiner, undefined);
Expand All @@ -1283,7 +1286,7 @@ function max$1(struct, maybeMessage, thanValue) {
if (value <= thanValue) {
return ;
} else {
return Belt_Option.getWithDefault(maybeMessage, "Number must be lower than or equal to " + thanValue.toString());
return Belt_Option.getWithDefault(maybeMessage, "Number must be lower than or equal to " + thanValue.toString() + "");
}
};
return refine(struct, refiner, refiner, undefined);
Expand Down
Loading