In my code, TypeScript is only used to provide type hints for developers, without participating in the compilation checks.
Maybe using window
is simpler, but I prefer globalThis
.
To avoid them polluting each other's globalThis.I want to know if it's possible to do this.
I want to attach types to globalThis, but the scope should be limited to a single file only.
File1.vue
<script setup lang="ts">
declare global {
var arrayOne: string[]
var arrayTwo: string[]
}
// globalThis.arrayThree X any type ts-plugin(7017)
</script>
<template>
</template>
File2.vue
<script setup lang="ts">
declare global {
var arrayOne: number[]
var arrayThree: number[]
}
// globalThis.arrayTwo X any type ts-plugin(7017)
</script>
<template>
</template>