Home / File/ svelte-shims.d.ts — astro Source File

svelte-shims.d.ts — astro Source File

Architecture documentation for svelte-shims.d.ts, a typescript file in the astro codebase. 2 imports, 0 dependents.

File typescript 2 imports

Entity Profile

Dependency Diagram

graph LR
  ce8de785_4317_2249_098f_efdef3441e2b["svelte-shims.d.ts"]
  dac9ee9a_059c_8059_903a_dbd37eec7d7b["svelte-shims-v4"]
  ce8de785_4317_2249_098f_efdef3441e2b --> dac9ee9a_059c_8059_903a_dbd37eec7d7b
  5cb493ec_f3a5_3354_a1cd_243d52fecf7f["jsx-runtime"]
  ce8de785_4317_2249_098f_efdef3441e2b --> 5cb493ec_f3a5_3354_a1cd_243d52fecf7f
  style ce8de785_4317_2249_098f_efdef3441e2b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import 'svelte2tsx/svelte-shims-v4';

import type { JSX } from 'astro/jsx-runtime';

export type AstroClientDirectives = JSX.AstroComponentDirectives;

type Snippet = import('svelte').Snippet;

/**
 * Helper to detect index-signature-like keys.
 */
type IsIndexSignatureKey<K> = string extends K
	? true
	: number extends K
		? true
		: symbol extends K
			? true
			: false;

/**
 * Removes index signatures whose value type is `never`.
 * (Keeps normal, explicitly-declared keys unchanged.)
 */
export type StripNeverIndexSignatures<T> = {
	[K in keyof T as IsIndexSignatureKey<K> extends true
		? [T[K]] extends [never]
			? never
			: K
		: K]: T[K];
};

/**
 * If `children` exists and is `never`, make it `{ children?: undefined }`
 * (works even when it was required).
 * If `children` doesn't exist, add `{ children?: undefined }`.
 */
type NormalizeNeverChildren<T> = 'children' extends keyof T
	? [T['children']] extends [never]
		? Omit<T, 'children'> & { children?: undefined }
		: T
	: T & { children?: undefined };

/**
 * If `children` includes `Snippet` (even as part of a union), widen to `any`
 * to allow arbitrary content.
 */
type WidenChildrenIfSnippet<T> = {
	[K in keyof T]: K extends 'children'
		? Extract<NonNullable<T[K]>, Snippet> extends never
			? T[K]
			: any
		: T[K];
};

/**
 * `T` (Svelte props) made safe for Astro:
 * - Normalize `children` (avoid `never`/missing cases)
 * - Widen snippet-based `children` to `any` (Astro slot/content compatibility)
 * - Strip useless `never` index signatures (allow extra keys like `client:*`)
 * - Add Astro client directives
 */
export type PropsWithClientDirectives<T> = StripNeverIndexSignatures<
	WidenChildrenIfSnippet<NormalizeNeverChildren<T>>
> &
	AstroClientDirectives;

Dependencies

  • jsx-runtime
  • svelte-shims-v4

Frequently Asked Questions

What does svelte-shims.d.ts do?
svelte-shims.d.ts is a source file in the astro codebase, written in typescript.
What does svelte-shims.d.ts depend on?
svelte-shims.d.ts imports 2 module(s): jsx-runtime, svelte-shims-v4.
Where is svelte-shims.d.ts in the architecture?
svelte-shims.d.ts is located at packages/integrations/svelte/svelte-shims.d.ts (directory: packages/integrations/svelte).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free