deprecated.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.DecimalLiteral = DecimalLiteral;
  6. exports.Noop = Noop;
  7. exports.RecordExpression = RecordExpression;
  8. exports.TSExpressionWithTypeArguments = TSExpressionWithTypeArguments;
  9. exports.TupleExpression = TupleExpression;
  10. function Noop() {}
  11. function TSExpressionWithTypeArguments(node) {
  12. this.print(node.expression);
  13. this.print(node.typeParameters);
  14. }
  15. function DecimalLiteral(node) {
  16. const raw = this.getPossibleRaw(node);
  17. if (!this.format.minified && raw !== undefined) {
  18. this.word(raw);
  19. return;
  20. }
  21. this.word(node.value + "m");
  22. }
  23. function RecordExpression(node) {
  24. const props = node.properties;
  25. let startToken;
  26. let endToken;
  27. if (this.format.recordAndTupleSyntaxType === "bar") {
  28. startToken = "{|";
  29. endToken = "|}";
  30. } else if (this.format.recordAndTupleSyntaxType !== "hash" && this.format.recordAndTupleSyntaxType != null) {
  31. throw new Error(`The "recordAndTupleSyntaxType" generator option must be "bar" or "hash" (${JSON.stringify(this.format.recordAndTupleSyntaxType)} received).`);
  32. } else {
  33. startToken = "#{";
  34. endToken = "}";
  35. }
  36. this.token(startToken);
  37. if (props.length) {
  38. this.space();
  39. this.printList(props, this.shouldPrintTrailingComma(endToken), true, true);
  40. this.space();
  41. }
  42. this.token(endToken);
  43. }
  44. function TupleExpression(node) {
  45. const elems = node.elements;
  46. const len = elems.length;
  47. let startToken;
  48. let endToken;
  49. if (this.format.recordAndTupleSyntaxType === "bar") {
  50. startToken = "[|";
  51. endToken = "|]";
  52. } else if (this.format.recordAndTupleSyntaxType === "hash") {
  53. startToken = "#[";
  54. endToken = "]";
  55. } else {
  56. throw new Error(`${this.format.recordAndTupleSyntaxType} is not a valid recordAndTuple syntax type`);
  57. }
  58. this.token(startToken);
  59. for (let i = 0; i < elems.length; i++) {
  60. const elem = elems[i];
  61. if (elem) {
  62. if (i > 0) this.space();
  63. this.print(elem);
  64. if (i < len - 1 || this.shouldPrintTrailingComma(endToken)) {
  65. this.token(",", false, i);
  66. }
  67. }
  68. }
  69. this.token(endToken);
  70. }
  71. //# sourceMappingURL=deprecated.js.map