Skip to content

Instantly share code, notes, and snippets.

@oussamahamdaoui
Created December 8, 2025 08:03
Show Gist options
  • Select an option

  • Save oussamahamdaoui/3792b7c79c0f0d4e3d693ff1a12d3293 to your computer and use it in GitHub Desktop.

Select an option

Save oussamahamdaoui/3792b7c79c0f0d4e3d693ff1a12d3293 to your computer and use it in GitHub Desktop.
Svelte isSnippet
// THIS IS A HACK, USE ON YOUR OWN RISK
<script module lang="ts">
import type { Snippet } from 'svelte';
const EmptySnippetKey = Object.getOwnPropertyNames(EmptySnippet).join('');
export function isSnippet<P extends unknown[] = []>(t: any): t is Snippet<P> {
return Object.getOwnPropertyNames(t).join('') == EmptySnippetKey;
}
</script>
{#snippet EmptySnippet()}{/snippet}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment