After bundling my JavaScript with the .net setting
BundleTable.EnableOptimizations = true;
, I've encountered a peculiar issue.
Here's the snippet of the generated code causing the error (simplified):
var somVar = new b({
searchUrl: "/someUrl",
data: n => {
query: n.term,
page: n.page,
teamId: this.props.teamId,
season: this.props.season
},
resultFormat: this.formatState,
resultSort: this.sortResults,
onSelect: this.handlePlayerSelect
});
But on line 5, it throws an Unexpected token :
error. I'm puzzled about why that might be happening. The scripts work fine without optimizations.
The non-optimized version looks like this:
var someVar = new Select2({
searchUrl: "/someUrl",
data: (params) => {
return {
query: params.term,
page: params.page,
teamId: this.props.teamId,
season: this.props.season
};
},
resultFormat: this.formatState,
resultSort: this.sortResults,
onSelect: this.handlePlayerSelect
})
This is the original TypeScript version:
new Select2({
searchUrl: "/someUrl",
data: (params: Select2QueryOptions) => {
return {
query: params.term,
page: params.page,
teamId: this.props.teamId,
season: this.props.season
}
},
resultFormat: this.formatState,
resultSort: this.sortResults,
onSelect: this.handlePlayerSelect
} as ISelect2Props)
This code is part of an array passed as a submodule to a base module, so there's no specific variable it's attached to here.