In my pursuit of creating a simplistic setup, I aim to incorporate the features mentioned above. In the realm of JavaScript code, below snippet plays a crucial role:
<script type="module" src="./myapp.js"></script>
This script is responsible for loading the myapp.js module. Within myapp.js, I intend to craft a Vue component utilizing TypeScript (myapp.ts) and then transpile it into JavaScript. However, achieving type information within the .ts code demands importing Vue typings through this method:
import Vue from 'vue'
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
});
Upon transpilation, thanks to my tsconfig.settings, the resulting JavaScript retains an es2015 module syntax as such:
import Vue from 'vue';
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
});
However, browsers tend to have issues with this named import format.
The inquiry ensues: How can one possibly import typings without resorting to the aforementioned statement? Despite attempts at utilizing /// syntax, the types remained elusive. Could this be due to the explicit exportation of types, necessitating their import via the traditional import syntax?
Is there a workaround for obtaining typings sans importation? Can the named import be used exclusively for typings retrieval while excluding that line from transpilation? Perhaps, is there an alternative approach to achieve this objective without delving into webpack or similar configurations?
Thank you, John.