@formatjs/ts-transformer
Advanced tools
Comparing version 1.1.6 to 1.1.7
@@ -6,2 +6,13 @@ # Change Log | ||
## [1.1.7](https://github.com/formatjs/formatjs/compare/@formatjs/ts-transformer@1.1.6...@formatjs/ts-transformer@1.1.7) (2020-05-06) | ||
### Bug Fixes | ||
* **@formatjs/ts-transformer:** expand extraction to `formatMessage()` as well ([146f1d3](https://github.com/formatjs/formatjs/commit/146f1d39fe0f42cba04dc25c391d03a5fbb39d28)) | ||
## 1.1.6 (2020-04-28) | ||
@@ -8,0 +19,0 @@ |
@@ -81,3 +81,3 @@ "use strict"; | ||
// We extracted nothing | ||
if (!Object.keys(msg).length) { | ||
if (!Object.entries(msg).find(([_, v]) => v)) { | ||
return; | ||
@@ -104,12 +104,19 @@ } | ||
} | ||
/** | ||
* Check if node is `intl.formatMessage` node | ||
* @param node | ||
* @param sf | ||
*/ | ||
function isIntlFormatMessageCall(node, sf) { | ||
const method = node.expression; | ||
if (!ts.isPropertyAccessExpression(method)) { | ||
return false; | ||
// Handle intl.formatMessage() | ||
if (ts.isPropertyAccessExpression(method)) { | ||
return ((method.name.getText(sf) === 'formatMessage' && | ||
ts.isIdentifier(method.expression) && | ||
method.expression.getText(sf) === 'intl') || | ||
(ts.isPropertyAccessExpression(method.expression) && | ||
method.expression.name.getText(sf) === 'intl')); | ||
} | ||
return ((method.name.getText(sf) === 'formatMessage' && | ||
ts.isIdentifier(method.expression) && | ||
method.expression.getText(sf) === 'intl') || | ||
(ts.isPropertyAccessExpression(method.expression) && | ||
method.expression.name.getText(sf) === 'intl')); | ||
// Handle formatMessage() | ||
return ts.isIdentifier(method) && method.getText(sf) === 'formatMessage'; | ||
} | ||
@@ -116,0 +123,0 @@ function extractMessageFromJsxComponent(node, program, sf, opts) { |
{ | ||
"name": "@formatjs/ts-transformer", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"description": "TS Compiler transformer for formatjs", | ||
@@ -39,3 +39,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "84e7cc6f3723801271661fdbdb5391fac7e6f74c" | ||
"gitHead": "31693b2c2371274e2371bcf4e82700bcad53ca74" | ||
} |
@@ -177,3 +177,3 @@ import * as ts from 'typescript'; | ||
// We extracted nothing | ||
if (!Object.keys(msg).length) { | ||
if (!Object.entries(msg).find(([_, v]) => v)) { | ||
return; | ||
@@ -210,15 +210,23 @@ } | ||
/** | ||
* Check if node is `intl.formatMessage` node | ||
* @param node | ||
* @param sf | ||
*/ | ||
function isIntlFormatMessageCall(node: ts.CallExpression, sf: ts.SourceFile) { | ||
const method = node.expression; | ||
if (!ts.isPropertyAccessExpression(method)) { | ||
return false; | ||
// Handle intl.formatMessage() | ||
if (ts.isPropertyAccessExpression(method)) { | ||
return ( | ||
(method.name.getText(sf) === 'formatMessage' && | ||
ts.isIdentifier(method.expression) && | ||
method.expression.getText(sf) === 'intl') || | ||
(ts.isPropertyAccessExpression(method.expression) && | ||
method.expression.name.getText(sf) === 'intl') | ||
); | ||
} | ||
return ( | ||
(method.name.getText(sf) === 'formatMessage' && | ||
ts.isIdentifier(method.expression) && | ||
method.expression.getText(sf) === 'intl') || | ||
(ts.isPropertyAccessExpression(method.expression) && | ||
method.expression.name.getText(sf) === 'intl') | ||
); | ||
// Handle formatMessage() | ||
return ts.isIdentifier(method) && method.getText(sf) === 'formatMessage'; | ||
} | ||
@@ -225,0 +233,0 @@ |
@@ -14,2 +14,5 @@ import {join} from 'path'; | ||
}, | ||
extractFromFormatMessageStateless: { | ||
extractFromFormatMessageCall: true, | ||
}, | ||
extractSourceLocation: { | ||
@@ -16,0 +19,0 @@ extractSourceLocation: true, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39
1251
167470