@formatjs/cli 6.7.0 → 6.7.2

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/bin/formatjs +74 -42
  2. package/package.json +2 -5
package/bin/formatjs CHANGED
@@ -18547,9 +18547,9 @@ var init_compile_folder = __esm({
18547
18547
  }
18548
18548
  });
18549
18549
 
18550
- // node_modules/.aspect_rules_js/typescript@5.8.2/node_modules/typescript/lib/typescript.js
18550
+ // node_modules/.aspect_rules_js/typescript@5.8.3/node_modules/typescript/lib/typescript.js
18551
18551
  var require_typescript = __commonJS({
18552
- "node_modules/.aspect_rules_js/typescript@5.8.2/node_modules/typescript/lib/typescript.js"(exports, module2) {
18552
+ "node_modules/.aspect_rules_js/typescript@5.8.3/node_modules/typescript/lib/typescript.js"(exports, module2) {
18553
18553
  var ts2 = {};
18554
18554
  ((module3) => {
18555
18555
  "use strict";
@@ -20819,7 +20819,7 @@ var require_typescript = __commonJS({
20819
20819
  });
20820
20820
  module3.exports = __toCommonJS2(typescript_exports);
20821
20821
  var versionMajorMinor = "5.8";
20822
- var version = "5.8.2";
20822
+ var version = "5.8.3";
20823
20823
  var Comparison = ((Comparison3) => {
20824
20824
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
20825
20825
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -77836,10 +77836,11 @@ ${lanes.join("\n")}
77836
77836
  serializeExistingTypeNode(context, typeNode, addUndefined) {
77837
77837
  return serializeExistingTypeNode(context, typeNode, !!addUndefined);
77838
77838
  },
77839
- serializeReturnTypeForSignature(syntacticContext, signatureDeclaration) {
77839
+ serializeReturnTypeForSignature(syntacticContext, signatureDeclaration, symbol) {
77840
77840
  const context = syntacticContext;
77841
77841
  const signature = getSignatureFromDeclaration(signatureDeclaration);
77842
- const returnType = context.enclosingSymbolTypes.get(getSymbolId(getSymbolOfDeclaration(signatureDeclaration))) ?? instantiateType(getReturnTypeOfSignature(signature), context.mapper);
77842
+ symbol ?? (symbol = getSymbolOfDeclaration(signatureDeclaration));
77843
+ const returnType = context.enclosingSymbolTypes.get(getSymbolId(symbol)) ?? instantiateType(getReturnTypeOfSignature(signature), context.mapper);
77843
77844
  return serializeInferredReturnTypeForSignature(context, signature, returnType);
77844
77845
  },
77845
77846
  serializeTypeOfExpression(syntacticContext, expr) {
@@ -77853,7 +77854,7 @@ ${lanes.join("\n")}
77853
77854
  symbol ?? (symbol = getSymbolOfDeclaration(declaration));
77854
77855
  let type = (_a = context.enclosingSymbolTypes) == null ? void 0 : _a.get(getSymbolId(symbol));
77855
77856
  if (type === void 0) {
77856
- type = symbol && !(symbol.flags & (2048 | 131072)) ? instantiateType(getWidenedLiteralType(getTypeOfSymbol(symbol)), context.mapper) : errorType;
77857
+ type = symbol.flags & 98304 && declaration.kind === 178 ? instantiateType(getWriteTypeOfSymbol(symbol), context.mapper) : symbol && !(symbol.flags & (2048 | 131072)) ? instantiateType(getWidenedLiteralType(getTypeOfSymbol(symbol)), context.mapper) : errorType;
77857
77858
  }
77858
77859
  const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration);
77859
77860
  if (addUndefinedForParameter) {
@@ -77920,6 +77921,7 @@ ${lanes.join("\n")}
77920
77921
  const context = syntacticContext;
77921
77922
  if (context.bundled || context.enclosingFile !== getSourceFileOfNode(lit)) {
77922
77923
  let name = lit.text;
77924
+ const originalName = name;
77923
77925
  const nodeSymbol = getNodeLinks(parent2).resolvedSymbol;
77924
77926
  const meaning = parent2.isTypeOf ? 111551 : 788968;
77925
77927
  const parentSymbol = nodeSymbol && isSymbolAccessible(
@@ -77949,7 +77951,9 @@ ${lanes.join("\n")}
77949
77951
  context.tracker.reportLikelyUnsafeImportRequiredError(name);
77950
77952
  }
77951
77953
  }
77952
- return name;
77954
+ if (name !== originalName) {
77955
+ return name;
77956
+ }
77953
77957
  }
77954
77958
  },
77955
77959
  canReuseTypeNode(context, typeNode) {
@@ -79139,6 +79143,7 @@ ${lanes.join("\n")}
79139
79143
  if (propertySymbol.flags & 98304) {
79140
79144
  const writeType = getWriteTypeOfSymbol(propertySymbol);
79141
79145
  if (propertyType !== writeType && !isErrorType(propertyType) && !isErrorType(writeType)) {
79146
+ const symbolMapper = getSymbolLinks(propertySymbol).mapper;
79142
79147
  const getterDeclaration = getDeclarationOfKind(
79143
79148
  propertySymbol,
79144
79149
  177
@@ -79148,7 +79153,7 @@ ${lanes.join("\n")}
79148
79153
  typeElements.push(
79149
79154
  setCommentRange2(
79150
79155
  context,
79151
- signatureToSignatureDeclarationHelper(getterSignature, 177, context, { name: propertyName }),
79156
+ signatureToSignatureDeclarationHelper(symbolMapper ? instantiateSignature(getterSignature, symbolMapper) : getterSignature, 177, context, { name: propertyName }),
79152
79157
  getterDeclaration
79153
79158
  )
79154
79159
  );
@@ -79161,7 +79166,7 @@ ${lanes.join("\n")}
79161
79166
  typeElements.push(
79162
79167
  setCommentRange2(
79163
79168
  context,
79164
- signatureToSignatureDeclarationHelper(setterSignature, 178, context, { name: propertyName }),
79169
+ signatureToSignatureDeclarationHelper(symbolMapper ? instantiateSignature(setterSignature, symbolMapper) : setterSignature, 178, context, { name: propertyName }),
79165
79170
  setterDeclaration
79166
79171
  )
79167
79172
  );
@@ -80436,13 +80441,13 @@ ${lanes.join("\n")}
80436
80441
  const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration);
80437
80442
  const decl = declaration ?? symbol.valueDeclaration ?? getDeclarationWithTypeAnnotation(symbol) ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
80438
80443
  if (decl) {
80444
+ const restore = addSymbolTypeToContext(context, symbol, type);
80439
80445
  if (isAccessor(decl)) {
80440
80446
  result = syntacticNodeBuilder.serializeTypeOfAccessor(decl, symbol, context);
80441
80447
  } else if (hasInferredType(decl) && !nodeIsSynthesized(decl) && !(getObjectFlags(type) & 196608)) {
80442
- const restore = addSymbolTypeToContext(context, symbol, type);
80443
80448
  result = syntacticNodeBuilder.serializeTypeOfDeclaration(decl, symbol, context);
80444
- restore();
80445
80449
  }
80450
+ restore();
80446
80451
  }
80447
80452
  if (!result) {
80448
80453
  if (addUndefinedForParameter) {
@@ -80615,10 +80620,7 @@ ${lanes.join("\n")}
80615
80620
  /*context*/
80616
80621
  void 0
80617
80622
  );
80618
- if (updated !== node2) {
80619
- setTextRange2(context, updated, node2);
80620
- }
80621
- return updated;
80623
+ return setTextRange2(context, updated, node2);
80622
80624
  }
80623
80625
  }
80624
80626
  function serializeTypeName(context, node, isTypeOf, typeArguments) {
@@ -106321,6 +106323,11 @@ ${lanes.join("\n")}
106321
106323
  ])) {
106322
106324
  grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead);
106323
106325
  }
106326
+ if (compilerOptions.erasableSyntaxOnly) {
106327
+ const start = skipTrivia(file.text, node.pos);
106328
+ const end = node.expression.pos;
106329
+ diagnostics.add(createFileDiagnostic(file, start, end - start, Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled));
106330
+ }
106324
106331
  }
106325
106332
  return checkAssertionWorker(node, checkMode);
106326
106333
  }
@@ -165775,9 +165782,11 @@ ${lanes.join("\n")}
165775
165782
  if (!resolver.canReuseTypeNode(context, node)) {
165776
165783
  return resolver.serializeExistingTypeNode(context, node);
165777
165784
  }
165785
+ const specifier = rewriteModuleSpecifier2(node, node.argument.literal);
165786
+ const literal = specifier === node.argument.literal ? reuseNode(context, node.argument.literal) : specifier;
165778
165787
  return factory.updateImportTypeNode(
165779
165788
  node,
165780
- factory.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier2(node, node.argument.literal)),
165789
+ literal === node.argument.literal ? reuseNode(context, node.argument) : factory.createLiteralTypeNode(literal),
165781
165790
  visitNode(node.attributes, visitExistingNodeTreeSymbols, isImportAttributes),
165782
165791
  visitNode(node.qualifier, visitExistingNodeTreeSymbols, isEntityName),
165783
165792
  visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode),
@@ -165939,10 +165948,7 @@ ${lanes.join("\n")}
165939
165948
  }
165940
165949
  function rewriteModuleSpecifier2(parent2, lit) {
165941
165950
  const newName = resolver.getModuleSpecifierOverride(context, parent2, lit);
165942
- if (newName) {
165943
- return setOriginalNode(factory.createStringLiteral(newName), lit);
165944
- }
165945
- return visitNode(lit, visitExistingNodeTreeSymbols, isStringLiteral);
165951
+ return newName ? setOriginalNode(factory.createStringLiteral(newName), lit) : lit;
165946
165952
  }
165947
165953
  }
165948
165954
  }
@@ -166118,12 +166124,7 @@ ${lanes.join("\n")}
166118
166124
  return withNewScope(context, node, () => serializeTypeAnnotationOfDeclaration(accessorType, context, node, symbol) ?? inferTypeOfDeclaration(node, symbol, context));
166119
166125
  }
166120
166126
  if (accessorDeclarations.getAccessor) {
166121
- return withNewScope(context, accessorDeclarations.getAccessor, () => createReturnFromSignature(
166122
- accessorDeclarations.getAccessor,
166123
- /*symbol*/
166124
- void 0,
166125
- context
166126
- ));
166127
+ return withNewScope(context, accessorDeclarations.getAccessor, () => createReturnFromSignature(accessorDeclarations.getAccessor, symbol, context));
166127
166128
  }
166128
166129
  return void 0;
166129
166130
  }
@@ -166242,7 +166243,7 @@ ${lanes.join("\n")}
166242
166243
  /* AnyKeyword */
166243
166244
  );
166244
166245
  }
166245
- function inferReturnTypeOfSignatureSignature(node, context, reportFallback) {
166246
+ function inferReturnTypeOfSignatureSignature(node, context, symbol, reportFallback) {
166246
166247
  if (reportFallback) {
166247
166248
  context.tracker.reportInferenceFallback(node);
166248
166249
  }
@@ -166252,7 +166253,7 @@ ${lanes.join("\n")}
166252
166253
  /* AnyKeyword */
166253
166254
  );
166254
166255
  }
166255
- return resolver.serializeReturnTypeForSignature(context, node) ?? factory.createKeywordTypeNode(
166256
+ return resolver.serializeReturnTypeForSignature(context, node, symbol) ?? factory.createKeywordTypeNode(
166256
166257
  133
166257
166258
  /* AnyKeyword */
166258
166259
  );
@@ -166567,18 +166568,17 @@ ${lanes.join("\n")}
166567
166568
  );
166568
166569
  }
166569
166570
  function reuseTypeParameters(typeParameters, context) {
166570
- return typeParameters == null ? void 0 : typeParameters.map(
166571
- (tp) => {
166572
- var _a;
166573
- return factory.updateTypeParameterDeclaration(
166574
- tp,
166575
- (_a = tp.modifiers) == null ? void 0 : _a.map((m) => reuseNode(context, m)),
166576
- reuseNode(context, tp.name),
166577
- serializeExistingTypeNodeWithFallback(tp.constraint, context),
166578
- serializeExistingTypeNodeWithFallback(tp.default, context)
166579
- );
166580
- }
166581
- );
166571
+ return typeParameters == null ? void 0 : typeParameters.map((tp) => {
166572
+ var _a;
166573
+ const { node: tpName } = resolver.trackExistingEntityName(context, tp.name);
166574
+ return factory.updateTypeParameterDeclaration(
166575
+ tp,
166576
+ (_a = tp.modifiers) == null ? void 0 : _a.map((m) => reuseNode(context, m)),
166577
+ tpName,
166578
+ serializeExistingTypeNodeWithFallback(tp.constraint, context),
166579
+ serializeExistingTypeNodeWithFallback(tp.default, context)
166580
+ );
166581
+ });
166582
166582
  }
166583
166583
  function typeFromObjectLiteralMethod(method, name, context, isConstContext) {
166584
166584
  const returnType = createReturnFromSignature(
@@ -166733,7 +166733,7 @@ ${lanes.join("\n")}
166733
166733
  } else if (isValueSignatureDeclaration(fn)) {
166734
166734
  returnType = typeFromSingleReturnExpression(fn, context);
166735
166735
  }
166736
- return returnType.type !== void 0 ? returnType.type : inferReturnTypeOfSignatureSignature(fn, context, reportFallback && returnType.reportFallback && !returnTypeNode);
166736
+ return returnType.type !== void 0 ? returnType.type : inferReturnTypeOfSignatureSignature(fn, context, symbol, reportFallback && returnType.reportFallback && !returnTypeNode);
166737
166737
  }
166738
166738
  function typeFromSingleReturnExpression(declaration, context) {
166739
166739
  let candidateExpr;
@@ -230184,6 +230184,22 @@ var require_transform = __commonJS({
230184
230184
  msg.description = initializer.text;
230185
230185
  break;
230186
230186
  }
230187
+ } else if (ts2.isTaggedTemplateExpression(initializer)) {
230188
+ const { template } = initializer;
230189
+ if (!ts2.isNoSubstitutionTemplateLiteral(template)) {
230190
+ throw new Error("Tagged template expression must be no substitution");
230191
+ }
230192
+ switch (name.text) {
230193
+ case "id":
230194
+ msg.id = template.text;
230195
+ break;
230196
+ case "defaultMessage":
230197
+ msg.defaultMessage = template.text;
230198
+ break;
230199
+ case "description":
230200
+ msg.description = template.text;
230201
+ break;
230202
+ }
230187
230203
  } else if (ts2.isJsxExpression(initializer) && initializer.expression) {
230188
230204
  if (ts2.isStringLiteral(initializer.expression)) {
230189
230205
  switch (name.text) {
@@ -230212,6 +230228,22 @@ var require_transform = __commonJS({
230212
230228
  msg.description = expression.text;
230213
230229
  break;
230214
230230
  }
230231
+ } else if (ts2.isTaggedTemplateExpression(initializer.expression)) {
230232
+ const { expression: { template } } = initializer;
230233
+ if (!ts2.isNoSubstitutionTemplateLiteral(template)) {
230234
+ throw new Error("Tagged template expression must be no substitution");
230235
+ }
230236
+ switch (name.text) {
230237
+ case "id":
230238
+ msg.id = template.text;
230239
+ break;
230240
+ case "defaultMessage":
230241
+ msg.defaultMessage = template.text;
230242
+ break;
230243
+ case "description":
230244
+ msg.description = template.text;
230245
+ break;
230246
+ }
230215
230247
  } else if (ts2.isBinaryExpression(initializer.expression)) {
230216
230248
  const { expression } = initializer;
230217
230249
  const [result, isStatic] = evaluateStringConcat(ts2, expression);
@@ -231194,7 +231226,7 @@ sentences are not translator-friendly.`
231194
231226
  debug("Reading inFile:", cmdObj.inFile);
231195
231227
  const inFile = (0, import_fs_extra5.readFileSync)(cmdObj.inFile, "utf8");
231196
231228
  files.push(
231197
- ...inFile.split("\n").filter(Boolean).map((f) => (0, import_path4.resolve)(f))
231229
+ ...inFile.split(/\n|\s+/).filter(Boolean).map((f) => (0, import_path4.resolve)(f))
231198
231230
  );
231199
231231
  }
231200
231232
  debug("Files to extract:", files);
package/package.json CHANGED
@@ -1,20 +1,17 @@
1
1
  {
2
2
  "name": "@formatjs/cli",
3
3
  "description": "A CLI for formatjs.",
4
- "version": "6.7.0",
4
+ "version": "6.7.2",
5
5
  "license": "MIT",
6
6
  "author": "Linjie Ding <linjie@airtable.com>",
7
7
  "engines": {
8
8
  "node": ">= 16"
9
9
  },
10
10
  "devDependencies": {
11
- "@formatjs/cli-lib": "7.4.0"
11
+ "@formatjs/cli-lib": "7.4.2"
12
12
  },
13
13
  "peerDependencies": {
14
- "@glimmer/env": "^0.1.7",
15
- "@glimmer/reference": "^0.94.0",
16
14
  "@glimmer/syntax": "^0.94.9",
17
- "@glimmer/validator": "^0.94.0",
18
15
  "@vue/compiler-core": "^3.5.12",
19
16
  "content-tag": "^3.0.0",
20
17
  "ember-template-recast": "^6.1.5",