mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
The name property is inherited from Error and has a type of string. But our CustomError ensures that the name is restricted to the type of T. This causes compiler errors, so we had to enable a babel plugin to support it.
35 lines
666 B
JavaScript
35 lines
666 B
JavaScript
'use strict';
|
|
|
|
const babelJest = require('babel-jest').default;
|
|
|
|
const hasJsxRuntime = (() => {
|
|
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
require.resolve('react/jsx-runtime');
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
})();
|
|
|
|
module.exports = babelJest.createTransformer({
|
|
plugins: [
|
|
['@babel/plugin-transform-typescript', {
|
|
allowDeclareFields: true
|
|
}],
|
|
'@shopify/react-i18n/babel'],
|
|
presets: [
|
|
[
|
|
require.resolve('babel-preset-react-app'),
|
|
{
|
|
runtime: hasJsxRuntime ? 'automatic' : 'classic',
|
|
},
|
|
],
|
|
],
|
|
babelrc: false,
|
|
configFile: false,
|
|
});
|