You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
I was running into an issue using TypeScript 3.7 with optional chaining and React Fragments using empty tags (<>...</>). In order to get both working properly the TypeScript preprocessor needs some minimal changes:
diff --git a/node_modules/i18n-tag-schema/dist/lib/preprocessors/typescript.js b/node_modules/i18n-tag-schema/dist/lib/preprocessors/typescript.js
index 0e5cd94..60923e3 100644
--- a/node_modules/i18n-tag-schema/dist/lib/preprocessors/typescript.js+++ b/node_modules/i18n-tag-schema/dist/lib/preprocessors/typescript.js@@ -15,8 +15,8 @@ exports.default = function (contents, filePath) {
if (!ts) throw new Error('cannot find typescript compiler. check if \'typescript\' node module is installed.');
var processed = ts.transpileModule(contents, {
compilerOptions: {
- target: ts.ScriptTarget.Latest,- jsx: path.extname(filePath) !== '.ts' ? ts.JsxEmit.Preserve : ts.JsxEmit.None+ target: ts.ScriptTarget.ES2020,+ jsx: path.extname(filePath) !== '.ts' ? ts.JsxEmit.React : ts.JsxEmit.None
}
});
if (processed && processed.outputText) {
By setting ES2020 we force transpiling optional chaining syntax (such as foo?.bar and foo ?? bar). ts.JsxEmit.React is needed for proper fragment support.
The text was updated successfully, but these errors were encountered:
I don't want to enable ES2020 for the default preprocessor because it is still a draft. But you could release your preprocessor as an npm package with more sophisticated features and configurations. https://github.com/skolmer/i18n-tag-schema#-preprocessors
I could add a link to your npm package to the readme of this repository.
The preprocessor that comes out of the box is really just a basic implementation for starters and to show what's possible with this library.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I was running into an issue using TypeScript 3.7 with optional chaining and React Fragments using empty tags (
<>...</>
). In order to get both working properly the TypeScript preprocessor needs some minimal changes:By setting
ES2020
we force transpiling optional chaining syntax (such asfoo?.bar
andfoo ?? bar
).ts.JsxEmit.React
is needed for proper fragment support.The text was updated successfully, but these errors were encountered: