i18next-scanner icon indicating copy to clipboard operation
i18next-scanner copied to clipboard

Are there any plans to support TypeScript?

Open KonradLinkowski opened this issue 3 years ago • 5 comments

🚀 Feature Proposal

Support for TypeScript files

Motivation

It's impossible to parse .ts and .tsx files now which makes it hard to use with any modern project

Example

It would fix errors like:

i18next-scanner: Unable to parse Trans component from "/path/to/file.tsx"
SyntaxError: Unexpected token (6:10)

It would close #88 and #179

KonradLinkowski avatar Nov 16 '22 10:11 KonradLinkowski

maybe, you can try converting to js in the transform function of the config.js file

dangyuzheng avatar Nov 16 '22 10:11 dangyuzheng

Use a custom transform, you can easily compile ts/tsx file to ES5/ES6 and extract translations.

parachvte avatar Dec 19 '22 12:12 parachvte

Maybe a bit late. Anyhow, this is what we use to scan tsx files:

rm -rf tmp/i18n && npx tsc --skipLibCheck -target es6 --module esnext --jsx preserve --outDir tmp/i18n && npx i18next-scanner --config i18next-scanner.config.js tmp/i18n/**/*.{js,jsx} && rm -rf tmp/i18n

mxsxs2 avatar Jan 12 '23 15:01 mxsxs2

Don't know about plans, but this should help parsing ts files https://github.com/i18next/i18next-scanner/issues/88#issuecomment-562446459

czabaj avatar Feb 28 '23 09:02 czabaj