I am creating interactive infographics using Google Charts and Kotlin JS. This is snippet from Quick Start Page.
var data = new google.visualization.DataTable();
<..>
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
Here "new" keyword is used. I tried to rewrite this code using Kotlin.
val data = google.visualization.DataTable();
<..>
val chart = google.visualization.PieChart(document.getElementById('chart_div'));
But an error occurred saying that "new" keyword is missing in lines above. So Kotlin to JS compiler haven't added the keyword where they should be. Here is compiled JavaScript code.
var data = google.visualization.DataTable();
<..>
var chart = google.visualization.PieChart(document.getElementById('chart_div'));
Is there correct way to avoid the error without using js() function?
Thank you.
jsfunction for all native Javascript object creation anyway. Is your avoidance ofjson principle, or did you see this type of call work without thejsfunction elsewhere?new, meaning very different things, and KT doesn't know which you mean.google.visualization.DataTable); as far as Kotlin knows, maybe DataTable is a plain function. Perhaps you need correspondingexternal classheaders as XMLHttpRequest does, but even then it's unclear whether it would work with the built-ingoogle.visualizationnamespacing.