Browse Source

Splits global types into global.d.ts

main
Eric Amodio 2 years ago
parent
commit
ac6fd1a87b
3 changed files with 23 additions and 22 deletions
  1. +21
    -0
      src/@types/global.d.ts
  2. +1
    -21
      src/constants.ts
  3. +1
    -1
      src/webviews/apps/tsconfig.json

+ 21
- 0
src/@types/global.d.ts View File

@ -0,0 +1,21 @@
export declare global {
export type PartialDeep<T> = T extends Record<string, unknown> ? { [K in keyof T]?: PartialDeep<T[K]> } : T;
export type Optional<T, K extends keyof T> = Omit<T, K> & { [P in K]?: T[P] };
export type PickPartialDeep<T, K extends keyof T> = Omit<Partial<T>, K> & { [P in K]?: Partial<T[P]> };
export type Mutable<T> = { -readonly [P in keyof T]: T[P] };
export type PickMutable<T, K extends keyof T> = Omit<T, K> & { -readonly [P in K]: T[P] };
export type ExcludeSome<T, K extends keyof T, R> = Omit<T, K> & { [P in K]-?: Exclude<T[P], R> };
export type ExtractAll<T, U> = { [K in keyof T]: T[K] extends U ? T[K] : never };
export type ExtractSome<T, K extends keyof T, R> = Omit<T, K> & { [P in K]-?: Extract<T[P], R> };
export type RequireSome<T, K extends keyof T> = Omit<T, K> & { [P in K]-?: T[P] };
export type AllNonNullable<T> = { [P in keyof T]-?: NonNullable<T[P]> };
export type SomeNonNullable<T, K extends keyof T> = Omit<T, K> & { [P in K]-?: NonNullable<T[P]> };
export type NarrowRepo<T extends { repo?: unknown }> = ExcludeSome<T, 'repo', string | undefined>;
export type NarrowRepos<T extends { repos?: unknown }> = ExcludeSome<T, 'repos', string | string[] | undefined>;
}

+ 1
- 21
src/constants.ts View File

@ -1,24 +1,3 @@
declare global {
export type PartialDeep<T> = T extends Record<string, unknown> ? { [K in keyof T]?: PartialDeep<T[K]> } : T;
export type PickPartialDeep<T, K extends keyof T> = Omit<Partial<T>, K> & { [P in K]?: Partial<T[P]> };
export type Mutable<T> = { -readonly [P in keyof T]: T[P] };
export type PickMutable<T, K extends keyof T> = Omit<T, K> & { -readonly [P in K]: T[P] };
export type ExcludeSome<T, K extends keyof T, R> = Omit<T, K> & { [P in K]-?: Exclude<T[P], R> };
export type ExtractAll<T, U> = { [K in keyof T]: T[K] extends U ? T[K] : never };
export type ExtractSome<T, K extends keyof T, R> = Omit<T, K> & { [P in K]-?: Extract<T[P], R> };
export type RequireSome<T, K extends keyof T> = Omit<T, K> & { [P in K]-?: T[P] };
export type AllNonNullable<T> = { [P in keyof T]-?: NonNullable<T[P]> };
export type SomeNonNullable<T, K extends keyof T> = Omit<T, K> & { [P in K]-?: NonNullable<T[P]> };
export type NarrowRepo<T extends { repo?: unknown }> = ExcludeSome<T, 'repo', string | undefined>;
export type NarrowRepos<T extends { repos?: unknown }> = ExcludeSome<T, 'repos', string | string[] | undefined>;
}
export const quickPickTitleMaxChars = 80;
export const ImageMimetypes: Record<string, string> = {
'.png': 'image/png',
@ -67,6 +46,7 @@ export const enum Colors {
export const enum Commands {
ActionPrefix = 'gitlens.action.',
AddAuthors = 'gitlens.addAuthors',
BrowseRepoAtRevision = 'gitlens.browseRepoAtRevision',
BrowseRepoAtRevisionInNewWindow = 'gitlens.browseRepoAtRevisionInNewWindow',

+ 1
- 1
src/webviews/apps/tsconfig.json View File

@ -4,6 +4,6 @@
"lib": ["dom", "dom.iterable", "es2020"],
"outDir": "../../"
},
"include": ["**/*", "../../../system/date.ts", "../../config.ts", "../protocol.ts"],
"include": ["**/*", "../../@types/**/*", "../../system/date.ts", "../../config.ts", "../protocol.ts"],
"exclude": ["node_modules", "test"]
}

Loading…
Cancel
Save