Every time I compile TypeScript using @babel/plugin-transform-typescript, I encounter a warning.
The issue seems to be caused by another plugin injecting "_class" without properly registering it in the scope tracker. If you are the creator of that plugin, please ensure to use "scope.registerDeclaration(declarationPath)". The identifier "_class" is not recognized as a JavaScript value binding in Babel's scope tracker and "@babel/plugin-transform-typescript" does not recognize it as a TypeScript type declaration either. Therefore, it will be treated as a regular JavaScript value.
I've been struggling to find out the root cause of this problem.
Below is my babel.config.js
configuration:
module.exports = {
presets: ['@babel/preset-typescript', '@babel/preset-react', '@babel/preset-env', 'mobx'],
plugins: [
['@babel/plugin-transform-typescript', { allowNamespaces: true }],
// List of various plugins
'@babel/plugin-proposal-function-bind',
// Other stage 0 plugins...
'@babel/plugin-proposal-throw-expressions',
'@babel/plugin-proposal-object-rest-spread',
// Remaining stage 2 and stage 3 plugins...
// Additional plugins
'@babel/plugin-transform-runtime',
'@babel/plugin-transform-modules-commonjs',
'jsx-control-statements'
]
}
Additionally, here is part of my webpack.config.js
:
module.exports = {
// ...
resolve: {
extensions: ['.js', '.ts', '.tsx'] // Resolvable extensions
},
module: {
rules: [
{
test: /\.[tj]sx?$/,
loader: 'babel-loader',
},
]
}
};
My program functions correctly with this setup. Even switching to ts-loader
works fine too.
If anyone can provide some guidance on resolving this issue, I would greatly appreciate it. Thank you!