-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
43 lines (34 loc) · 1.53 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: MIT-0
// Copyright 2024 Amazon
type AnyFn = (...args: any[]) => any;
type VoidFn = () => void;
type NoArgsFn = () => any;
type Thunk<F extends AnyFn> = () => ReturnType<F>;
type Wrapper<F extends AnyFn> = (...args: Parameters<F>) => ReturnType<F>;
type VoidWrapper<F extends AnyFn> = (...args: Parameters<F>) => void;
type LinkAs = 'audio' | 'document' | 'fetch' | 'font' | 'image' | 'object'
| 'script' | 'style' | 'track' | 'video' | 'worker';
// Opaque<T, K> cannot be assigned from T
// T is assignable from Opaque<T, K>
type Opaque<T, K> = T & { __opaque__: K };
// StrongOpaque<T, K> cannot be assigned from T
// T cannot be assigned from StrongOpaque<T, K>
type StrongOpaque<T, K> = (T & { __opaque__: K }) | { __opaque__: K };
type EncodedURIComponent = Opaque<string, 'EncodedURIComponent'>;
type URLString = Opaque<string, 'URLString'>;
type WithReferrerPolicy<T> = T & {referrerPolicy: ReferrerPolicy};
interface _FeaturePolicy {
allowsFeature: () => true;
allowedFeatures: () => string[];
features: () => string[];
getAllowlistForFeature: (feature: string) => string[];
}
type WithFeaturePolicy<T> = T & {featurePolicy?: _FeaturePolicy};
interface RequestInitExt extends RequestInit {
referrerPolicy?: ReferrerPolicy;
priority?: 'high' | 'low' | 'auto';
}
interface ElementCreator {
<K extends "iframe">(target: Document | HTMLElement, type: K): WithFeaturePolicy<HTMLIFrameElement>;
<K extends keyof HTMLElementTagNameMap>(target: Document | HTMLElement, type: K): HTMLElementTagNameMap[K];
}