I ran into an issue while trying to dynamically import a single file vue component within itself in TypeScript. The error message I received was:
/Users/lilei/Desktop/designer-web/node_modules/fork-ts-checker-webpack-plugin/lib/service.js:22
throw error;
^
RangeError: Maximum call stack size exceeded
at getSymbolLinks (/Users/lilei/Desktop/designer-web/node_modules/typescript/lib/typescript.js:31794:32)
at getDeclaredTypeOfTypeAlias (/Users/lilei/Desktop/designer-web/node_modules/typescript/lib/typescript.js:36457:25)
...
The file in question is named myComp.vue
<template>
<div>
<my-comp v-if="someCondition"></my-comp>
</div>
</template>
<script lang="ts">
export default Vue.extend({
data(){
return{};
},
components:{
myComp:()=>import('./myComp.vue')//Which is the name of current file, this is a official usage for dynamic loading vue component, and every thing is right in native JavaScript(not in TypeScript)
}
})
</script>
It seems that there are recursive tasks being executed during TypeScript compilation, leading to the error. However, I have ensured that the component does not infinitely nest itself by controlling the someCondition in my logic. How can I dynamically import a .vue file recursively in TypeScript?