Init commit

This commit is contained in:
ShreejitPanchal
2026-05-19 19:56:02 +08:00
commit 6601501eff
4047 changed files with 2185372 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
{
"name": "@peertube/peertube-typescript-utils",
"private": true,
"version": "0.0.0",
"main": "dist/index.js",
"files": [ "dist" ],
"exports": {
"types": "./dist/index.d.ts",
"peertube:tsx": "./src/index.ts",
"default": "./dist/index.js"
},
"type": "module",
"devDependencies": {},
"scripts": {
"build": "tsc",
"watch": "tsc -w"
},
"dependencies": {}
}

View File

@@ -0,0 +1 @@
export * from './types.js'

View File

@@ -0,0 +1,54 @@
/* eslint-disable @typescript-eslint/array-type */
export type FunctionPropertyNames<T> = {
[K in keyof T]: T[K] extends Function ? K : never
}[keyof T]
export type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>
export type AttributesOnly<T> = {
[K in keyof T]: T[K] extends Function ? never : T[K]
}
export type PickWith<T, KT extends keyof T, V> = {
[P in KT]: T[P] extends V ? V : never
}
export type PickWithOpt<T, KT extends keyof T, V> = {
[P in KT]?: T[P] extends V ? V : never
}
// https://github.com/krzkaczor/ts-essentials Rocks!
export type DeepPartial<T> = {
[P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>>
: T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
: DeepPartial<T[P]>
}
type Primitive = string | Function | number | boolean | symbol | undefined | null
export type DeepOmitHelper<T, K extends keyof T> = {
[P in K]: // extra level of indirection needed to trigger homomorhic behavior
T[P] extends infer TP // distribute over unions
? TP extends Primitive ? TP // leave primitives and functions alone
: TP extends any[] ? DeepOmitArray<TP, K> // Array special handling
: DeepOmit<TP, K>
: never
}
export type DeepOmit<T, K> = T extends Primitive ? T : DeepOmitHelper<T, Exclude<keyof T, K>>
export type DeepOmitArray<T extends any[], K> = {
[P in keyof T]: DeepOmit<T[P], K>
}
export type Unpacked<T> = T extends (infer U)[] ? U : T
export type Awaitable<T> = T | PromiseLike<T>
// Thanks https://stackoverflow.com/a/52761156
export type OverloadedParameters<T> =
// eslint-disable-next-line max-len
T extends { (...args: infer A1): any, (...args: infer A2): any, (...args: infer A3): any, (...args: infer A4): any } ? A1 | A2 | A3 | A4 :
T extends { (...args: infer A1): any, (...args: infer A2): any, (...args: infer A3): any } ? A1 | A2 | A3 :
T extends { (...args: infer A1): any, (...args: infer A2): any } ? A1 | A2 :
T extends (...args: infer A) => any ? A
: any

View File

@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "src",
"tsBuildInfoFile": "./dist/.tsbuildinfo"
}
}

View File

@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../types-generator/dist-tmp/peertube-typescript-utils",
"tsBuildInfoFile": "../types-generator/dist-tmp/peertube-typescript-utils/.tsbuildinfo",
"stripInternal": true,
"removeComments": false,
"emitDeclarationOnly": true
}
}