From 0ac7324c44ec177af6dd8433f34ab4ad95521747 Mon Sep 17 00:00:00 2001 From: Anthony Le Courric Date: Fri, 22 Dec 2023 12:32:58 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85(frontend)=20adapt=20babel=20to=20inte?= =?UTF-8?q?rpret=20declare=20keyword=20in=20typescript?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we adapted the class in the plugin video.js, we use the keyword "declare", which is not interpreted by babel. We need to add a plugin to babel to interpret this keyword correctly. --- src/frontend/apps/lti_site/babel.config.js | 6 ++++++ src/frontend/apps/lti_site/package.json | 1 + src/frontend/apps/standalone_site/babel.config.js | 6 ++++++ src/frontend/apps/standalone_site/package.json | 1 + src/frontend/package.json | 1 + src/frontend/packages/lib_video/babel.config.js | 6 ++++++ src/frontend/packages/lib_video/package.json | 1 + src/frontend/yarn.lock | 2 +- 8 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/frontend/apps/lti_site/babel.config.js b/src/frontend/apps/lti_site/babel.config.js index f2000080a6..f04423b09b 100644 --- a/src/frontend/apps/lti_site/babel.config.js +++ b/src/frontend/apps/lti_site/babel.config.js @@ -1,5 +1,11 @@ module.exports = { plugins: [ + [ + '@babel/plugin-transform-typescript', + { + allowDeclareFields: true, + }, + ], [ 'react-intl', { diff --git a/src/frontend/apps/lti_site/package.json b/src/frontend/apps/lti_site/package.json index 2ffb14e735..9c983eb1c8 100644 --- a/src/frontend/apps/lti_site/package.json +++ b/src/frontend/apps/lti_site/package.json @@ -25,6 +25,7 @@ "@babel/core": "7.23.9", "@babel/plugin-proposal-class-properties": "7.18.6", "@babel/plugin-syntax-dynamic-import": "7.8.3", + "@babel/plugin-transform-typescript": "*", "@babel/polyfill": "7.12.1", "@babel/preset-env": "7.23.9", "@babel/preset-react": "7.23.3", diff --git a/src/frontend/apps/standalone_site/babel.config.js b/src/frontend/apps/standalone_site/babel.config.js index 7d64c7ff5f..340c2acdd4 100644 --- a/src/frontend/apps/standalone_site/babel.config.js +++ b/src/frontend/apps/standalone_site/babel.config.js @@ -12,6 +12,12 @@ module.exports = babelJest.createTransformer({ ast: true, }, ], + [ + '@babel/plugin-transform-typescript', + { + allowDeclareFields: true, + }, + ], 'babel-plugin-import-remove-resource-query', '@babel/plugin-syntax-dynamic-import', 'babel-plugin-transform-vite-meta-env', diff --git a/src/frontend/apps/standalone_site/package.json b/src/frontend/apps/standalone_site/package.json index ccf5d5689f..b6e9577798 100644 --- a/src/frontend/apps/standalone_site/package.json +++ b/src/frontend/apps/standalone_site/package.json @@ -39,6 +39,7 @@ "devDependencies": { "@babel/core": "7.23.9", "@babel/plugin-syntax-dynamic-import": "7.8.3", + "@babel/plugin-transform-typescript": "*", "@babel/preset-env": "7.23.9", "@babel/preset-typescript": "7.23.3", "@testing-library/jest-dom": "*", diff --git a/src/frontend/package.json b/src/frontend/package.json index fc7eeba0fb..822793b93d 100644 --- a/src/frontend/package.json +++ b/src/frontend/package.json @@ -40,6 +40,7 @@ }, "resolutions": { "@babel/plugin-proposal-private-property-in-object": "7.21.11", + "@babel/plugin-transform-typescript": "7.23.6", "@codemirror/lang-markdown": "6.2.4", "@codemirror/language": "6.10.1", "@codemirror/language-data": "6.4.1", diff --git a/src/frontend/packages/lib_video/babel.config.js b/src/frontend/packages/lib_video/babel.config.js index 4bfd2bff38..6419139179 100644 --- a/src/frontend/packages/lib_video/babel.config.js +++ b/src/frontend/packages/lib_video/babel.config.js @@ -8,6 +8,12 @@ module.exports = { ast: true, }, ], + [ + '@babel/plugin-transform-typescript', + { + allowDeclareFields: true, + }, + ], '@babel/proposal-class-properties', '@babel/plugin-syntax-dynamic-import', '@babel/plugin-transform-runtime', diff --git a/src/frontend/packages/lib_video/package.json b/src/frontend/packages/lib_video/package.json index 421a23f7a9..fdb283aea8 100644 --- a/src/frontend/packages/lib_video/package.json +++ b/src/frontend/packages/lib_video/package.json @@ -33,6 +33,7 @@ "@babel/plugin-proposal-class-properties": "7.18.6", "@babel/plugin-syntax-dynamic-import": "7.8.3", "@babel/plugin-transform-runtime": "7.23.9", + "@babel/plugin-transform-typescript": "*", "@babel/polyfill": "7.12.1", "@babel/preset-env": "7.23.9", "@babel/preset-typescript": "7.23.3", diff --git a/src/frontend/yarn.lock b/src/frontend/yarn.lock index adc0711533..a9af785795 100644 --- a/src/frontend/yarn.lock +++ b/src/frontend/yarn.lock @@ -1116,7 +1116,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-typescript@^7.23.3": +"@babel/plugin-transform-typescript@*", "@babel/plugin-transform-typescript@7.23.6", "@babel/plugin-transform-typescript@^7.23.3": version "7.23.6" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.23.6.tgz#aa36a94e5da8d94339ae3a4e22d40ed287feb34c" integrity sha512-6cBG5mBvUu4VUD04OHKnYzbuHNP8huDsD3EDqqpIpsswTDoqHCjLoHb6+QgsV1WsT2nipRqCPgxD3LXnEO7XfA==