refactor: fix a lot of errors in type-aware linting (#7477)

This commit is contained in:
Joshua Chen 2022-05-24 15:40:26 +08:00 committed by GitHub
parent 222bf3c091
commit bf1513a3e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
120 changed files with 407 additions and 364 deletions

View file

@ -65,20 +65,22 @@ async function askForPackageManagerChoice(): Promise<PackageManager> {
.map((p) => ({title: p, value: p}));
return (
(await prompts(
{
type: 'select',
name: 'packageManager',
message: 'Select a package manager...',
choices,
},
{
onCancel() {
logger.info`Falling back to name=${defaultPackageManager}`;
(
(await prompts(
{
type: 'select',
name: 'packageManager',
message: 'Select a package manager...',
choices,
},
},
)) as {packageManager: PackageManager}
).packageManager;
{
onCancel() {
logger.info`Falling back to name=${defaultPackageManager}`;
},
},
)) as {packageManager: PackageManager}
).packageManager ?? defaultPackageManager
);
}
async function getPackageManager(
@ -101,8 +103,7 @@ async function getPackageManager(
(await findPackageManagerFromLockFile('.')) ??
findPackageManagerFromUserAgent() ??
// This only happens if the user has a global installation in PATH
(skipInstall ? defaultPackageManager : askForPackageManagerChoice()) ??
defaultPackageManager
(skipInstall ? defaultPackageManager : askForPackageManagerChoice())
);
}
@ -215,7 +216,7 @@ async function getGitCommand(gitStrategy: GitStrategy): Promise<string> {
logger.info`Falling back to code=${'git clone'}`;
},
},
)) as {command: string};
)) as {command?: string};
return command ?? 'git clone';
}
case 'deep':
@ -362,7 +363,7 @@ async function getSource(
)) as {gitRepoUrl: string};
let strategy = cliOptions.gitStrategy;
if (!strategy) {
({strategy} = await prompts(
({strategy} = (await prompts(
{
type: 'select',
name: 'strategy',
@ -385,7 +386,7 @@ async function getSource(
logger.info`Falling back to name=${'deep'}`;
},
},
));
)) as {strategy?: GitStrategy});
}
return {
type: 'git',
@ -426,13 +427,13 @@ async function getSource(
}
let useTS = cliOptions.typescript;
if (!useTS && template.tsVariantPath) {
({useTS} = await prompts({
({useTS} = (await prompts({
type: 'confirm',
name: 'useTS',
message:
'This template is available in TypeScript. Do you want to use the TS variant?',
initial: false,
}));
})) as {useTS?: boolean});
}
return {
type: 'template',