lukasgeiter / gettext-extractor

A flexible and powerful Gettext message extractor with support for JavaScript, TypeScript, JSX and HTML.
MIT License
98 stars 21 forks source link

Better exception message #20

Open konuch opened 5 years ago

konuch commented 5 years ago

When extractor tries to extract a given line which contains syntaxt error, for example it contains

translate.instant('test1' + 'text2')

, it fails with following error, which is alright:

.\node_modules\gettext-extractor\dist\js\extractors\factories\callExpression.js:93
    let concatenated = ts.createStringLiteral('');
                                       ^
TypeError: ts.createStringLiteral is not a function

However, the stacktrace does not contain any relevant information about the file and line number, where the extraction failed.

Would it be possible to include this information somehow, so developer knows where he made an error? Maybe adding some try/catch block.

Thanks in advance.

lukasgeiter commented 5 years ago

Thanks, that's a good suggestion. I'll see if I can improve this in a future release...


With the error you posted you've actually found a bug. Concatenated strings are supported, but there was an issue with TypeScript 2.8 and lower. The bug is now fixed in release v3.4.1.