@formatjs/ts-transformer
Advanced tools
Comparing version
@@ -6,2 +6,13 @@ # Change Log | ||
## [1.0.6](https://github.com/formatjs/formatjs/compare/@formatjs/ts-transformer@1.0.5...@formatjs/ts-transformer@1.0.6) (2019-11-08) | ||
### Bug Fixes | ||
* **@formatjs/ts-transformer:** handle props.intl.formatMessage case ([afaa03d](https://github.com/formatjs/formatjs/commit/afaa03d3104145523c11ebe3ba85f92e560ee8a7)) | ||
## [1.0.5](https://github.com/formatjs/formatjs/compare/@formatjs/ts-transformer@1.0.4...@formatjs/ts-transformer@1.0.5) (2019-11-07) | ||
@@ -8,0 +19,0 @@ |
@@ -109,6 +109,11 @@ "use strict"; | ||
function isIntlFormatMessageCall(node, sf) { | ||
const expr = node.expression; | ||
return (ts.isPropertyAccessExpression(expr) && | ||
expr.expression.getText(sf) === 'intl' && | ||
expr.name.getText(sf) === 'formatMessage'); | ||
const method = node.expression; | ||
if (!ts.isPropertyAccessExpression(method)) { | ||
return false; | ||
} | ||
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')); | ||
} | ||
@@ -115,0 +120,0 @@ function extractMessageFromJsxComponent(node, program, sf, opts) { |
{ | ||
"name": "@formatjs/ts-transformer", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "TS Compiler transformer for formatjs", | ||
@@ -33,3 +33,3 @@ "main": "dist/index.js", | ||
"homepage": "https://github.com/formatjs/formatjs#readme", | ||
"gitHead": "ad39ea58e53cc2b90a3a56bb332fc5ab12ecf219" | ||
"gitHead": "6b8c35f93d4824636b587cfef323aba1494109a4" | ||
} |
@@ -221,7 +221,13 @@ import * as ts from 'typescript'; | ||
function isIntlFormatMessageCall(node: ts.CallExpression, sf: ts.SourceFile) { | ||
const expr = node.expression; | ||
const method = node.expression; | ||
if (!ts.isPropertyAccessExpression(method)) { | ||
return false; | ||
} | ||
return ( | ||
ts.isPropertyAccessExpression(expr) && | ||
expr.expression.getText(sf) === 'intl' && | ||
expr.name.getText(sf) === 'formatMessage' | ||
(method.name.getText(sf) === 'formatMessage' && | ||
(ts.isIdentifier(method.expression) && | ||
method.expression.getText(sf) === 'intl')) || | ||
(ts.isPropertyAccessExpression(method.expression) && | ||
method.expression.name.getText(sf) === 'intl') | ||
); | ||
@@ -228,0 +234,0 @@ } |
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
65274
3.03%1242
1.47%