TypeError: _super.apply is not a function
See original GitHub issueExpected Behavior
No errors to console.
Actual Behavior
Error is thrown on chart creation.
Environment
- vue.js version: 2.6.10
- chart.js version: 2.9.3
- vue-chart.js version: 3.5.0
- npm version: 6.4.1
- typescript: 3.7.2
- @types/chart.js version: 2.9.5
import { Scatter } from "vue-chartjs";
import { Component, Prop, Watch } from "vue-property-decorator";
export interface IPlot {
data: Object,
options: Object,
}
@Component({
"extends": Scatter,
})
export default class BasePlot extends Scatter {
@Prop({ required: true })
plot!: IPlot; // `!` means we know this variable will not be null
isMounted = false;
mounted() {
// Overwriting base render method with actual data.
this.isMounted = true;
this.renderChart(this.plot.data, this.plot.options);
}
@Watch("plot", { deep: false, immediate: false })
onPlotChanged(value: Object, oldValue: Object) {
if (this.isMounted) { //catch error when watcher runs before mounted()
this.renderChart(this.plot.data, this.plot.options);
}
}
}
In this project I am required to use Typescript. The only example for using vue-chartjs with Typescript utilizes the Component syntax, so this is how I implemented it above.
The offending line is this:
export default class BasePlot extends Scatter {
This all works just fine. However, it throws these errors to the console whenever the chart is created:
vue.esm.js:628 [Vue warn]: Error in data(): "TypeError: _super.apply is not a function"
found in
---> <BasePlot>
<CalcZ> at Scripts/app/components/capacitor/simulation/CalcZ.vue
<App> at Scripts/app/components/App.vue
<Root>
warn @ vue.esm.js:628
logError @ vue.esm.js:1893
globalHandleError @ vue.esm.js:1888
handleError @ vue.esm.js:1848
getData @ vue.esm.js:4753
initData @ vue.esm.js:4708
initState @ vue.esm.js:4645
Vue._init @ vue.esm.js:5009
VueComponent @ vue.esm.js:5157
createComponentInstanceForVnode @ vue.esm.js:3292
init @ vue.esm.js:3123
createComponent @ vue.esm.js:5983
createElm @ vue.esm.js:5930
createChildren @ vue.esm.js:6058
createElm @ vue.esm.js:5959
createChildren @ vue.esm.js:6058
createElm @ vue.esm.js:5959
createChildren @ vue.esm.js:6058
createElm @ vue.esm.js:5959
patch @ vue.esm.js:6482
Vue._update @ vue.esm.js:3948
updateComponent @ vue.esm.js:4069
get @ vue.esm.js:4482
Watcher @ vue.esm.js:4471
mountComponent @ vue.esm.js:4076
Vue.$mount @ vue.esm.js:9057
Vue.$mount @ vue.esm.js:11953
init @ vue.esm.js:3127
merged @ vue.esm.js:3310
createComponent @ vue.esm.js:5983
createElm @ vue.esm.js:5930
createChildren @ vue.esm.js:6058
createElm @ vue.esm.js:5959
createChildren @ vue.esm.js:6058
createElm @ vue.esm.js:5959
createChildren @ vue.esm.js:6058
createElm @ vue.esm.js:5959
patch @ vue.esm.js:6482
Vue._update @ vue.esm.js:3948
updateComponent @ vue.esm.js:4069
get @ vue.esm.js:4482
Watcher @ vue.esm.js:4471
mountComponent @ vue.esm.js:4076
Vue.$mount @ vue.esm.js:9057
Vue.$mount @ vue.esm.js:11953
init @ vue.esm.js:3127
createComponent @ vue.esm.js:5983
createElm @ vue.esm.js:5930
patch @ vue.esm.js:6521
Vue._update @ vue.esm.js:3948
updateComponent @ vue.esm.js:4069
get @ vue.esm.js:4482
Watcher @ vue.esm.js:4471
mountComponent @ vue.esm.js:4076
Vue.$mount @ vue.esm.js:9057
Vue.$mount @ vue.esm.js:11953
eval @ index.ts:21
./Scripts/app/index.ts @ app.js:2185
__webpack_require__ @ app.js:727
fn @ app.js:101
0 @ app.js:6298
__webpack_require__ @ app.js:727
(anonymous) @ app.js:794
(anonymous) @ app.js:797
Show 34 more frames
vue.esm.js:1897 TypeError: _super.apply is not a function
at new BasePlot (base-plot.ts:15)
at collectDataFromConstructor (vue-class-component.esm.js:97)
at VueComponent.data (vue-class-component.esm.js:172)
at VueComponent.mergedDataFn (vue.esm.js:1228)
at getData (vue.esm.js:4751)
at initData (vue.esm.js:4708)
at initState (vue.esm.js:4645)
at VueComponent.Vue._init (vue.esm.js:5009)
at new BasePlot (vue.esm.js:5157)
at createComponentInstanceForVnode (vue.esm.js:3292)
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
vue.js - How to solve "_super.apply is not a function" in VueJS ...
TypeError : _super.apply is not a function. Can anyone help me with what to do? Also all my files are compiled and I...
Read more >TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >The 10 Most Common JavaScript Issues Developers Face
Today, JavaScript is at the core of virtually all modern web applications. That's why JavaScript issues, ... Uncaught TypeError: undefined is not a...
Read more >1782102 – JS ERROR: TypeError: super._onDestroy is not a ...
Bug 1782102 - JS ERROR: TypeError: super._onDestroy is not a function. Summary: JS ERROR: TypeError: super. ... Attachments, (Terms of Use).
Read more >How to solve "_super.apply is not a function" in VueJS ...
Coding example for the question How to solve "_super.apply is not a function" in VueJS component (TypeScript)-Vue.js.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Don’t know what else to suggest then. See my working code below and try and make it match.
getSettings()
is just a method to return my settings, I have a number of computed properties in it.Hmm… good catch… that was some very old code.
I updated that interface to be
ChartData
andChartOptions
instead ofObject
for the types, but it doesn’t seem to be the problem.