deprecated.js 2.3 KB

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