Skip to content

Instantly share code, notes, and snippets.

View mmiszy's full-sized avatar
❤️
https://github.com/sponsors/typeofweb

Michał Miszczyszyn mmiszy

❤️
https://github.com/sponsors/typeofweb
View GitHub Profile
@franky47
franky47 / stripe-webhooks.ts
Created December 21, 2021 09:44
Strongly-typed webhook handlers for Stripe (Node.js)
import type { Stripe } from 'stripe'
export type StripeWebhookEventTypes =
Stripe.WebhookEndpointCreateParams.EnabledEvent
export type StripeWebhookEvent<
EventType extends StripeWebhookEventTypes,
Payload
> = {
eventType: EventType
@ClickerMonkey
ClickerMonkey / types.ts
Last active February 6, 2024 07:21
Typescript Helper Types
// when T is any|unknown, Y is returned, otherwise N
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N;
// when T is never, Y is returned, otherwise N
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
// when T is a tuple, Y is returned, otherwise N
// valid tuples = [string], [string, boolean],
// invalid tuples = [], string[], (string | number)[]
@vsaarinen
vsaarinen / zendesk.d.ts
Created November 4, 2019 09:44
TypeScript definitions for the Zendesk Web Widget
interface ZendeskWidget {
(
type: 'webWidget:on' | 'webWidget' | 'webWidget:get',
command: string,
payload?: any,
): void;
(
type: 'webWidget',
command: 'updateSettings',
payload: ZendeskSettings,
at, /^ATU[A-Z0-9]{9,9}$/,
be, /^BE[0-9]{10,10}$/,
bg, /^BG[0-9]{9,10}$/,
cy, /^CY[A-Z0-9]{9,9}$/,
cz, /^CZ[0-9]{8,10}$/,
de, /^DE[0-9]{9,9}$/,
dk, /^DK[0-9]{8,8}$/,
ee, /^EE[0-9]{9,9}$/,
el, /^EL[0-9]{9,9}$/,
es, /^ES[A-Z0-9]{9,9}$/,