我发现了一些通用代码,它让我难以理解它是如何工作的.我不明白它在哪里获得用于T的泛型类型.这是一个过于简单的示例,但我仍然不明白这是如何有效的Java代码.
public static void main(String[] args) {
System.out.print(get());
}
public static <T> T get()
{
return (T) getObj();
}
public static Object getObj()
{
return Boolean.FALSE;
}
Run Code Online (Sandbox Code Playgroud) 我的项目的一个依赖项是使用箭头函数,我似乎无法让 babel-loader 转译外部依赖项。
我的模块部分看起来像
module: {
rules: [
{test: /\.(js|jsx)$/, loader: 'babel-loader'}
]
}
Run Code Online (Sandbox Code Playgroud)
我最初在规则对象中有 exclude: /node_modules/(?!superagent)/ ,但删除了它以确保它不是正则表达式问题。
.babelrc
{
"presets": [
"@babel/env",
"@babel/react"
]
}
Run Code Online (Sandbox Code Playgroud)
索引.js
import superagent from 'superagent'
superagent.get('http://www.google.com')
.then(result=>console.log('done'))
.catch(e=>console.error(e));
Run Code Online (Sandbox Code Playgroud)
在这种情况下,有问题的依赖是 superagent
我用显示问题的配置创建了一个最小的 repo https://github.com/ksmith97/WebpackIssue
我不确定这里还有什么可以尝试的
编辑:要清楚这是为了 IE 11 支持。