chore: add extra types for empty array definitions

This commit is contained in:
Daniel Roe 2024-06-13 22:47:24 +01:00
parent 7dfc85623b
commit 02945b9fa6
No known key found for this signature in database
GPG Key ID: CBC814C393D93268
5 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,4 @@
import type { Component, PropType } from 'vue' import type { Component, PropType, VNode } from 'vue'
import { Fragment, Teleport, computed, createStaticVNode, createVNode, defineComponent, getCurrentInstance, h, nextTick, onMounted, ref, toRaw, watch, withMemo } from 'vue' import { Fragment, Teleport, computed, createStaticVNode, createVNode, defineComponent, getCurrentInstance, h, nextTick, onMounted, ref, toRaw, watch, withMemo } from 'vue'
import { debounce } from 'perfect-debounce' import { debounce } from 'perfect-debounce'
import { hash } from 'ohash' import { hash } from 'ohash'
@ -29,7 +29,7 @@ const getId = import.meta.client ? () => (id++).toString() : randomUUID
const components = import.meta.client ? new Map<string, Component>() : undefined const components = import.meta.client ? new Map<string, Component>() : undefined
async function loadComponents (source = appBaseURL, paths: NuxtIslandResponse['components']) { async function loadComponents (source = appBaseURL, paths: NuxtIslandResponse['components']) {
const promises = [] const promises: Array<Promise<void>> = []
for (const component in paths) { for (const component in paths) {
if (!(components!.has(component))) { if (!(components!.has(component))) {
@ -259,7 +259,7 @@ export default defineComponent({
// should away be triggered ONE tick after re-rendering the static node // should away be triggered ONE tick after re-rendering the static node
withMemo([teleportKey.value], () => { withMemo([teleportKey.value], () => {
const teleports = [] const teleports: Array<VNode> = []
// this is used to force trigger Teleport when vue makes the diff between old and new node // this is used to force trigger Teleport when vue makes the diff between old and new node
const isKeyOdd = teleportKey.value === 0 || !!(teleportKey.value && !(teleportKey.value % 2)) const isKeyOdd = teleportKey.value === 0 || !!(teleportKey.value && !(teleportKey.value % 2))

View File

@ -86,7 +86,7 @@ export function vforToArray (source: any): any[] {
if (import.meta.dev && !Number.isInteger(source)) { if (import.meta.dev && !Number.isInteger(source)) {
console.warn(`The v-for range expect an integer value but got ${source}.`) console.warn(`The v-for range expect an integer value but got ${source}.`)
} }
const array = [] const array: number[] = []
for (let i = 0; i < source; i++) { for (let i = 0; i < source; i++) {
array[i] = i array[i] = i
} }

View File

@ -698,7 +698,7 @@ const RESTART_RE = /^(?:app|error|app\.config)\.(?:js|ts|mjs|jsx|tsx|vue)$/i
function deduplicateArray<T = unknown> (maybeArray: T): T { function deduplicateArray<T = unknown> (maybeArray: T): T {
if (!Array.isArray(maybeArray)) { return maybeArray } if (!Array.isArray(maybeArray)) { return maybeArray }
const fresh = [] const fresh: any[] = []
const hashes = new Set<string>() const hashes = new Set<string>()
for (const item of maybeArray) { for (const item of maybeArray) {
const _hash = hash(item) const _hash = hash(item)

View File

@ -400,7 +400,7 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
// 2. Styles // 2. Styles
head.push({ style: inlinedStyles }) head.push({ style: inlinedStyles })
if (!isRenderingIsland || import.meta.dev) { if (!isRenderingIsland || import.meta.dev) {
const link = [] const link: Link[] = []
for (const style in styles) { for (const style in styles) {
const resource = styles[style] const resource = styles[style]
// Do not add links to resources that are inlined (vite v5+) // Do not add links to resources that are inlined (vite v5+)

View File

@ -232,7 +232,7 @@ export async function getRouteMeta (contents: string, absolutePath: string): Pro
} }
if (property.value.type === 'ArrayExpression') { if (property.value.type === 'ArrayExpression') {
const values = [] const values: string[] = []
for (const element of property.value.elements) { for (const element of property.value.elements) {
if (!element) { if (!element) {
continue continue