Skip to content

Commit

Permalink
Updates dependencies & TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Jan 14, 2021
1 parent 20b1920 commit eb9e7c3
Show file tree
Hide file tree
Showing 16 changed files with 161 additions and 133 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9010,12 +9010,12 @@
"@types/node": "12.12.70",
"@types/sortablejs": "1.10.6",
"@types/vscode": "1.52.0",
"@typescript-eslint/eslint-plugin": "4.12.0",
"@typescript-eslint/parser": "4.12.0",
"@typescript-eslint/eslint-plugin": "4.13.0",
"@typescript-eslint/parser": "4.13.0",
"circular-dependency-plugin": "5.2.2",
"clean-webpack-plugin": "3.0.0",
"copy-webpack-plugin": "7.0.0",
"csp-html-webpack-plugin": "5.0.1",
"csp-html-webpack-plugin": "5.1.0",
"css-loader": "5.0.1",
"eslint": "7.17.0",
"eslint-cli": "1.1.1",
Expand All @@ -9027,15 +9027,15 @@
"html-webpack-skip-assets-plugin": "0.0.2",
"image-minimizer-webpack-plugin": "2.2.0",
"imagemin-webp": "6.0.0",
"mini-css-extract-plugin": "1.3.3",
"mini-css-extract-plugin": "1.3.4",
"node-sass": "5.0.0",
"prettier": "2.2.1",
"sass-loader": "10.1.0",
"sass-loader": "10.1.1",
"terser-webpack-plugin": "5.1.1",
"ts-loader": "8.0.14",
"typescript": "4.0.5",
"typescript": "4.2.0-beta",
"vsce": "1.83.0",
"webpack": "5.12.3",
"webpack": "5.14.0",
"webpack-bundle-analyzer": "4.3.0",
"webpack-cli": "4.2.0"
}
Expand Down
9 changes: 4 additions & 5 deletions src/commands/git/branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Container } from '../../container';
import { GitBranchReference, GitReference, Repository } from '../../git/git';
import {
appendReposToTitle,
AsyncStepResultGenerator,
inputBranchNameStep,
PartialStepState,
pickBranchesStep,
Expand Down Expand Up @@ -244,7 +245,7 @@ export class BranchGitCommand extends QuickCommand<State> {
return QuickCommand.canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
}

private async *createCommandSteps(state: CreateStepState, context: Context): StepResultGenerator<void> {
private async *createCommandSteps(state: CreateStepState, context: Context): AsyncStepResultGenerator<void> {
if (state.flags == null) {
state.flags = [];
}
Expand Down Expand Up @@ -317,8 +318,7 @@ export class BranchGitCommand extends QuickCommand<State> {
return QuickCommand.canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
}

// eslint-disable-next-line @typescript-eslint/require-await
private async *deleteCommandSteps(state: DeleteStepState, context: Context): StepResultGenerator<void> {
private async *deleteCommandSteps(state: DeleteStepState, context: Context): AsyncStepResultGenerator<void> {
if (state.flags == null) {
state.flags = [];
}
Expand Down Expand Up @@ -422,8 +422,7 @@ export class BranchGitCommand extends QuickCommand<State> {
return QuickCommand.canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
}

// eslint-disable-next-line @typescript-eslint/require-await
private async *renameCommandSteps(state: RenameStepState, context: Context): StepResultGenerator<void> {
private async *renameCommandSteps(state: RenameStepState, context: Context): AsyncStepResultGenerator<void> {
if (state.flags == null) {
state.flags = [];
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/git/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { Container } from '../../container';
import { GitBranchReference, GitReference, Repository } from '../../git/git';
import {
appendReposToTitle,
AsyncStepResultGenerator,
PartialStepState,
pickRepositoriesStep,
QuickCommand,
QuickPickStep,
StepGenerator,
StepResult,
StepResultGenerator,
StepSelection,
StepState,
} from '../quickCommand';
Expand Down Expand Up @@ -130,7 +130,7 @@ export class FetchGitCommand extends QuickCommand<State> {
return state.counter < 0 ? StepResult.Break : undefined;
}

private async *confirmStep(state: FetchStepState, context: Context): StepResultGenerator<Flags[]> {
private async *confirmStep(state: FetchStepState, context: Context): AsyncStepResultGenerator<Flags[]> {
let lastFetchedOn = '';
if (state.repos.length === 1) {
const lastFetched = await state.repos[0].getLastFetched();
Expand Down
4 changes: 2 additions & 2 deletions src/commands/git/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Container } from '../../container';
import { GitBranch, GitLog, GitReference, GitRevision, Repository } from '../../git/git';
import {
appendReposToTitle,
AsyncStepResultGenerator,
PartialStepState,
pickBranchOrTagStep,
pickCommitStep,
Expand All @@ -12,7 +13,6 @@ import {
QuickPickStep,
StepGenerator,
StepResult,
StepResultGenerator,
StepSelection,
StepState,
} from '../quickCommand';
Expand Down Expand Up @@ -194,7 +194,7 @@ export class MergeGitCommand extends QuickCommand<State> {
return state.counter < 0 ? StepResult.Break : undefined;
}

private async *confirmStep(state: MergeStepState, context: Context): StepResultGenerator<Flags[]> {
private async *confirmStep(state: MergeStepState, context: Context): AsyncStepResultGenerator<Flags[]> {
const aheadBehind = await Container.git.getAheadBehindCommitCount(state.repo.path, [
GitRevision.createRange(context.destination.name, state.reference.name),
]);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/git/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { Container } from '../../container';
import { GitBranch, GitBranchReference, GitReference, Repository } from '../../git/git';
import {
appendReposToTitle,
AsyncStepResultGenerator,
PartialStepState,
pickRepositoriesStep,
QuickCommand,
QuickCommandButtons,
QuickPickStep,
StepGenerator,
StepResult,
StepResultGenerator,
StepSelection,
StepState,
} from '../quickCommand';
Expand Down Expand Up @@ -136,7 +136,7 @@ export class PullGitCommand extends QuickCommand<State> {
return state.counter < 0 ? StepResult.Break : undefined;
}

private async *confirmStep(state: PullStepState, context: Context): StepResultGenerator<Flags[]> {
private async *confirmStep(state: PullStepState, context: Context): AsyncStepResultGenerator<Flags[]> {
let step: QuickPickStep<FlagsQuickPickItem<Flags>>;

if (state.repos.length > 1) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/git/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Container } from '../../container';
import { GitBranch, GitBranchReference, GitReference, Repository } from '../../git/git';
import {
appendReposToTitle,
AsyncStepResultGenerator,
PartialStepState,
pickRepositoriesStep,
pickRepositoryStep,
Expand All @@ -13,7 +14,6 @@ import {
QuickPickStep,
StepGenerator,
StepResult,
StepResultGenerator,
StepSelection,
StepState,
} from '../quickCommand';
Expand Down Expand Up @@ -151,7 +151,7 @@ export class PushGitCommand extends QuickCommand<State> {
return state.counter < 0 ? StepResult.Break : undefined;
}

private async *confirmStep(state: PushStepState, context: Context): StepResultGenerator<Flags[]> {
private async *confirmStep(state: PushStepState, context: Context): AsyncStepResultGenerator<Flags[]> {
const useForceWithLease = configuration.getAny<boolean>('git.useForcePushWithLease') ?? false;

let step: QuickPickStep<FlagsQuickPickItem<Flags>>;
Expand Down
4 changes: 2 additions & 2 deletions src/commands/git/rebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Container } from '../../container';
import { GitBranch, GitLog, GitReference, GitRevision, Repository } from '../../git/git';
import {
appendReposToTitle,
AsyncStepResultGenerator,
PartialStepState,
pickBranchOrTagStep,
pickCommitStep,
Expand All @@ -13,7 +14,6 @@ import {
QuickPickStep,
StepGenerator,
StepResult,
StepResultGenerator,
StepSelection,
StepState,
} from '../quickCommand';
Expand Down Expand Up @@ -226,7 +226,7 @@ export class RebaseGitCommand extends QuickCommand<State> {
return state.counter < 0 ? StepResult.Break : undefined;
}

private async *confirmStep(state: RebaseStepState, context: Context): StepResultGenerator<Flags[]> {
private async *confirmStep(state: RebaseStepState, context: Context): AsyncStepResultGenerator<Flags[]> {
const aheadBehind = await Container.git.getAheadBehindCommitCount(state.repo.path, [
state.reference.refType === 'revision'
? GitRevision.createRange(state.reference.ref, context.destination.ref)
Expand Down
6 changes: 5 additions & 1 deletion src/commands/git/stash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { GitUri } from '../../git/gitUri';
import { GitActions, GitCommandsCommand } from '../gitCommands';
import {
appendReposToTitle,
AsyncStepResultGenerator,
PartialStepState,
pickRepositoryStep,
pickStashStep,
Expand Down Expand Up @@ -510,7 +511,10 @@ export class StashGitCommand extends QuickCommand<State> {
}
}

private async *pushCommandInputMessageStep(state: PushStepState, context: Context): StepResultGenerator<string> {
private async *pushCommandInputMessageStep(
state: PushStepState,
context: Context,
): AsyncStepResultGenerator<string> {
const step = QuickCommand.createInputStep({
title: appendReposToTitle(
context.title,
Expand Down
6 changes: 3 additions & 3 deletions src/commands/git/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Container } from '../../container';
import { GitReference, GitTagReference, Repository } from '../../git/git';
import {
appendReposToTitle,
AsyncStepResultGenerator,
inputTagNameStep,
PartialStepState,
pickBranchOrTagStep,
Expand Down Expand Up @@ -213,7 +214,7 @@ export class TagGitCommand extends QuickCommand<State> {
return QuickCommand.canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
}

private async *createCommandSteps(state: CreateStepState, context: Context): StepResultGenerator<void> {
private async *createCommandSteps(state: CreateStepState, context: Context): AsyncStepResultGenerator<void> {
if (state.flags == null) {
state.flags = [];
}
Expand Down Expand Up @@ -270,7 +271,7 @@ export class TagGitCommand extends QuickCommand<State> {
private async *createCommandInputMessageStep(
state: CreateStepState,
context: Context,
): StepResultGenerator<string> {
): AsyncStepResultGenerator<string> {
const step = QuickCommand.createInputStep({
title: appendReposToTitle(
`${context.title} at ${GitReference.toString(state.reference, { capitalize: true, icon: false })}`,
Expand Down Expand Up @@ -324,7 +325,6 @@ export class TagGitCommand extends QuickCommand<State> {
return QuickCommand.canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
}

// eslint-disable-next-line @typescript-eslint/require-await
private async *deleteCommandSteps(state: DeleteStepState, context: Context): StepGenerator {
while (this.canStepsContinue(state)) {
if (state.references != null && !Array.isArray(state.references)) {
Expand Down
31 changes: 18 additions & 13 deletions src/commands/quickCommand.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from '../git/git';
import { GitService } from '../git/gitService';
import {
AsyncStepResultGenerator,
PartialStepState,
QuickCommand,
QuickCommandButtons,
Expand Down Expand Up @@ -313,7 +314,7 @@ export async function* inputBranchNameStep<
state: State,
context: Context,
options: { placeholder: string; titleContext?: string; value?: string },
): StepResultGenerator<string> {
): AsyncStepResultGenerator<string> {
const step = QuickCommand.createInputStep({
title: appendReposToTitle(`${context.title}${options.titleContext ?? ''}`, state, context),
placeholder: options.placeholder,
Expand Down Expand Up @@ -348,7 +349,7 @@ export async function* inputTagNameStep<
state: State,
context: Context,
options: { placeholder: string; titleContext?: string; value?: string },
): StepResultGenerator<string> {
): AsyncStepResultGenerator<string> {
const step = QuickCommand.createInputStep({
title: appendReposToTitle(`${context.title}${options.titleContext ?? ''}`, state, context),
placeholder: options.placeholder,
Expand Down Expand Up @@ -393,7 +394,7 @@ export async function* pickBranchStep<
placeholder: string;
titleContext?: string;
},
): StepResultGenerator<GitBranchReference> {
): AsyncStepResultGenerator<GitBranchReference> {
const branches = await getBranches(state.repo, {
filterBranches: filterBranches,
picked: picked,
Expand Down Expand Up @@ -457,7 +458,7 @@ export async function* pickBranchesStep<
placeholder: string;
titleContext?: string;
},
): StepResultGenerator<GitBranchReference[]> {
): AsyncStepResultGenerator<GitBranchReference[]> {
const branches = await getBranches(state.repo, {
filterBranches: filterBranches,
picked: picked,
Expand Down Expand Up @@ -528,7 +529,7 @@ export async function* pickBranchOrTagStep<
additionalButtons?: QuickInputButton[];
ranges?: boolean;
},
): StepResultGenerator<GitReference> {
): AsyncStepResultGenerator<GitReference> {
context.showTags = true;

const showTagsButton = new QuickCommandButtons.ShowTagsToggle(context.showTags);
Expand Down Expand Up @@ -641,7 +642,7 @@ export async function* pickBranchOrTagStepMultiRepo<
titleContext?: string;
value?: string;
},
): StepResultGenerator<GitReference> {
): AsyncStepResultGenerator<GitReference> {
context.showTags = state.repos.length === 1;

const showTagsButton = new QuickCommandButtons.ShowTagsToggle(context.showTags);
Expand Down Expand Up @@ -765,7 +766,7 @@ export async function* pickCommitStep<
};
titleContext?: string;
},
): StepResultGenerator<GitLogCommit> {
): AsyncStepResultGenerator<GitLogCommit> {
function getItems(log: GitLog | undefined) {
return log == null
? [DirectiveQuickPickItem.create(Directive.Back, true), DirectiveQuickPickItem.create(Directive.Cancel)]
Expand Down Expand Up @@ -1011,7 +1012,11 @@ export function* pickCommitsStep<
export async function* pickContributorsStep<
State extends PartialStepState & { repo: Repository },
Context extends { repos: Repository[]; title: string }
>(state: State, context: Context, placeholder: string = 'Choose contributors'): StepResultGenerator<GitContributor[]> {
>(
state: State,
context: Context,
placeholder: string = 'Choose contributors',
): AsyncStepResultGenerator<GitContributor[]> {
const message = (await GitService.getBuiltInGitRepository(state.repo.path))?.inputBox.value;

const step = QuickCommand.createPickStep<ContributorQuickPickItem>({
Expand All @@ -1031,7 +1036,7 @@ export async function* pickContributorsStep<
export async function* pickRepositoryStep<
State extends PartialStepState & { repo?: string | Repository },
Context extends { repos: Repository[]; title: string }
>(state: State, context: Context, placeholder: string = 'Choose a repository'): StepResultGenerator<Repository> {
>(state: State, context: Context, placeholder: string = 'Choose a repository'): AsyncStepResultGenerator<Repository> {
if (typeof state.repo === 'string') {
state.repo = await Container.git.getRepository(state.repo);
if (state.repo != null) return state.repo;
Expand Down Expand Up @@ -1086,7 +1091,7 @@ export async function* pickRepositoriesStep<
state: State,
context: Context,
options?: { placeholder?: string; skipIfPossible?: boolean },
): StepResultGenerator<Repository[]> {
): AsyncStepResultGenerator<Repository[]> {
options = { placeholder: 'Choose repositories', skipIfPossible: false, ...options };

let actives: Repository[];
Expand Down Expand Up @@ -1259,7 +1264,7 @@ export async function* pickTagsStep<
placeholder: string;
titleContext?: string;
},
): StepResultGenerator<GitTagReference[]> {
): AsyncStepResultGenerator<GitTagReference[]> {
const tags = await getTags(state.repo, {
filterTags: filterTags,
picked: picked,
Expand Down Expand Up @@ -1313,7 +1318,7 @@ export async function* showCommitOrStashStep<
>(
state: State,
context: Context,
): StepResultGenerator<CommitFilesQuickPickItem | GitCommandQuickPickItem | CommandQuickPickItem> {
): AsyncStepResultGenerator<CommitFilesQuickPickItem | GitCommandQuickPickItem | CommandQuickPickItem> {
const step: QuickPickStep<
CommitFilesQuickPickItem | GitCommandQuickPickItem | CommandQuickPickItem
> = QuickCommand.createPickStep({
Expand Down Expand Up @@ -1638,7 +1643,7 @@ export async function* showCommitOrStashFileStep<
fileName: string;
},
Context extends { repos: Repository[]; title: string }
>(state: State, context: Context): StepResultGenerator<CommandQuickPickItem> {
>(state: State, context: Context): AsyncStepResultGenerator<CommandQuickPickItem> {
const step: QuickPickStep<CommandQuickPickItem> = QuickCommand.createPickStep<CommandQuickPickItem>({
title: appendReposToTitle(
GitReference.toString(state.reference, {
Expand Down
13 changes: 10 additions & 3 deletions src/commands/quickCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,16 @@ export namespace StepResult {
export const Break = Symbol('BreakStep');
}
export type StepResult<T> = typeof StepResult.Break | T;
export type StepResultGenerator<T> =
| Generator<QuickPickStep | QuickInputStep, StepResult<T>, any | undefined>
| AsyncGenerator<QuickPickStep | QuickInputStep, StepResult<T>, any | undefined>;
export type StepResultGenerator<T> = Generator<QuickPickStep | QuickInputStep, StepResult<T>, any | undefined>;
export type AsyncStepResultGenerator<T> = AsyncGenerator<
QuickPickStep | QuickInputStep,
StepResult<T>,
any | undefined
>;
// Can't use this union type because of https://github.com/microsoft/TypeScript/issues/41428
// export type StepResultGenerator<T> =
// | Generator<QuickPickStep | QuickInputStep, StepResult<T>, any | undefined>
// | AsyncGenerator<QuickPickStep | QuickInputStep, StepResult<T>, any | undefined>;
export type StepSelection<T> = T extends QuickPickStep<infer U>
? U[] | Directive
: T extends QuickInputStep
Expand Down

0 comments on commit eb9e7c3

Please sign in to comment.