-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As of 3.0.0, optional chaining in variables causes fatal errors. #205
Comments
any updates? |
I wasn't able to get this to work in 2.11.0 or 3.0.0 Any workarounds? I tried processing against the built |
It's a duplicate of this one: #178 |
@6uliver
|
Could you pretty please post an example? |
Sure, I'm using this config for acorn in my i18next-scanner.config.js:
|
Well I was hopeful I could just slide that into this scanner({
func: {
list: ['t'],
extensions: ['.js', '.ts', '.tsx'],
},
trans: {
acorn: {
ecmaVersion: 11,
sourceType: 'module',
},
},
nsSeparator: false,
keySeparator: false,
removeUnusedKeys: true,
sort: true,
lngs: ['de', 'en', 'es', 'es-MX', 'fr', 'it', 'ja', 'ko', 'pl', 'pt-BR', 'ru', 'zh-CHS', 'zh-CHT'],
defaultLng: 'en',
defaultValue: function (lng, ns, key) {
if (lng === 'en') {
return key;
} else if (en[key]) {
return `🦘 ${en[key]}`;
} else {
return '🦘';
}
},
resource: {
loadPath: 'src/locales/{{lng}}/{{ns}}.json',
savePath: 'src/locales/{{lng}}/{{ns}}.json',
},
}) Alas, same error. I guess it's the wrong property at wrong level or something |
I'm sorry, it works for me. By the way I'm not using Typescript. |
|
In the meantime I'm facing the same issue on another project which is using TypeScript. I've found a workaround which is not so ugly: transform the source files with TypeScript before processing it with the scanner. In the scanner config I'm using the i18next-scanner-typescript package (https://www.npmjs.com/package/i18next-scanner-typescript) the following way:
|
Yep I still have the problem. Will replacing esprima by acorn solved this ? |
It seems the |
A new version just published, this issue shall be resolved in v3.1.0 See https://www.npmjs.com/package/i18next-scanner for new versions cc @justrealmilk @genesiscz @joshuaja @ShenHongFei @6uliver @jgoncalv |
Haha uhhhh
|
I think |
No, it's not - it's a non-null assertion operator |
So far i18next-scanner does not have native support for TypeScript. You have to use TypeScript transpiler to transpile |
@cheton @justrealmilk I use i18next-scanner-typescript and it works quite well. |
Awesome! Thanks. |
{t('String {{string}}', { string: something.thing?.maybe })}
It won't process this while 2.11.0 would
The text was updated successfully, but these errors were encountered: