2023-06-05 19:15:12 +00:00
|
|
|
<script setup lang="ts">
|
2023-08-17 13:35:28 +00:00
|
|
|
import { ShouldNotBeKeyed } from '~/other-composables-folder/local'
|
|
|
|
|
2023-06-05 19:15:12 +00:00
|
|
|
function localScopedComposables () {
|
|
|
|
const _assert = (key?: string) => key ?? 'was not keyed'
|
|
|
|
|
|
|
|
function basic () {
|
|
|
|
function useState (key?: string) {
|
|
|
|
return _assert(key)
|
|
|
|
}
|
|
|
|
const useAsyncData = _assert
|
|
|
|
|
|
|
|
return [useState(), useAsyncData()]
|
|
|
|
}
|
|
|
|
|
|
|
|
function hoisting () {
|
|
|
|
return [useState()]
|
|
|
|
|
|
|
|
function useState (key?: string) {
|
|
|
|
return _assert(key)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function complex () {
|
|
|
|
const [useState] = [_assert]
|
|
|
|
const { a: useAsyncData } = {
|
|
|
|
a: _assert
|
|
|
|
}
|
|
|
|
const [_, { b: useLazyAsyncData }] = [null, {
|
|
|
|
b: _assert
|
|
|
|
}]
|
|
|
|
|
|
|
|
return [useState(), useAsyncData(), useLazyAsyncData()]
|
|
|
|
}
|
|
|
|
|
|
|
|
function deeperScope () {
|
|
|
|
const useState = _assert
|
|
|
|
|
|
|
|
return [(function () {
|
|
|
|
return useState()
|
|
|
|
})()]
|
|
|
|
}
|
|
|
|
|
2023-08-17 13:35:28 +00:00
|
|
|
function fromNonComponentFile () {
|
|
|
|
return [_assert(ShouldNotBeKeyed)]
|
|
|
|
}
|
|
|
|
|
2023-07-05 09:35:45 +00:00
|
|
|
function useCustomKeyedComposable (arg?: string) {
|
|
|
|
return _assert(arg)
|
|
|
|
}
|
2023-06-05 19:15:12 +00:00
|
|
|
|
2023-08-17 13:35:28 +00:00
|
|
|
return [...basic(), ...hoisting(), ...complex(), ...deeperScope(), ...fromNonComponentFile(), useCustomKeyedComposable()]
|
2023-07-05 09:35:45 +00:00
|
|
|
}
|
2023-06-05 19:15:12 +00:00
|
|
|
const skippedLocalScopedComposables = localScopedComposables().every(res => res === 'was not keyed')
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
{{ skippedLocalScopedComposables }}
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
body {
|
|
|
|
background-color: #000;
|
|
|
|
color: #fff;
|
|
|
|
}
|
|
|
|
</style>
|