mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
replace in checks with Object.hasOwn (#292956)
replace in checks with Object.hasOwn
This commit is contained in:
@@ -88,7 +88,7 @@ const mergeNamedObjectArrays = <T extends NamedObject>(
|
||||
if (!partial) {
|
||||
throw new Error('Invalid object passed to merge');
|
||||
}
|
||||
const existingNames = makeArray(partial.name).filter((name) => name in existingNameIndexMap);
|
||||
const existingNames = makeArray(partial.name).filter((name) => Object.hasOwn(existingNameIndexMap, name));
|
||||
if (existingNames.length === 0) {
|
||||
mergedObjects.push(partial);
|
||||
} else {
|
||||
|
||||
@@ -41,14 +41,14 @@ export function convertLoadSpec<ArgT, OptionT, SubcommandT>(
|
||||
|
||||
if (typeof loadSpec === 'function') {
|
||||
return (...args) =>
|
||||
loadSpec(...args).then((result) => {
|
||||
loadSpec(...args).then((result): Fig.SpecLocation[] | Subcommand<ArgT, OptionT, SubcommandT> => {
|
||||
if (Array.isArray(result)) {
|
||||
return result;
|
||||
return result as Fig.SpecLocation[];
|
||||
}
|
||||
if ('type' in result) {
|
||||
return [result];
|
||||
if (Object.hasOwn(result, 'type')) {
|
||||
return [result as Fig.SpecLocation];
|
||||
}
|
||||
return convertSubcommand(result, initialize);
|
||||
return convertSubcommand(result as Fig.Subcommand, initialize);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -277,7 +277,7 @@ export async function collectCompletionItemResult(
|
||||
let itemKind = kind;
|
||||
const lastArgType: string | undefined = parsedArguments?.annotations.at(-1)?.type;
|
||||
if (lastArgType === 'subcommand_arg') {
|
||||
if (typeof item === 'object' && 'args' in item && (asArray(item.args ?? [])).length > 0) {
|
||||
if (typeof item === 'object' && Object.hasOwn(item, 'args') && (asArray((item as Fig.Option).args ?? [])).length > 0) {
|
||||
itemKind = vscode.TerminalCompletionItemKind.Option;
|
||||
}
|
||||
}
|
||||
@@ -287,8 +287,8 @@ export async function collectCompletionItemResult(
|
||||
|
||||
// Add <argName> for every argument
|
||||
let detail: string | undefined;
|
||||
if (typeof item === 'object' && 'args' in item) {
|
||||
const args = asArray(item.args);
|
||||
if (typeof item === 'object' && Object.hasOwn(item, 'args')) {
|
||||
const args = asArray((item as Fig.Option).args);
|
||||
if (args.every(e => !!e?.name)) {
|
||||
if (args.length > 0) {
|
||||
detail = ' ' + args.map(e => {
|
||||
@@ -352,7 +352,7 @@ function convertEnvRecordToArray(env: Record<string, string>): EnvironmentVariab
|
||||
}
|
||||
|
||||
export function getFixSuggestionDescription(spec: Fig.Spec): string {
|
||||
if ('description' in spec) {
|
||||
if (typeof spec !== 'function' && Object.hasOwn(spec, 'description')) {
|
||||
return spec.description ?? '';
|
||||
}
|
||||
return '';
|
||||
|
||||
@@ -268,7 +268,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
const shellType: string | undefined = 'shell' in terminal.state ? terminal.state.shell as string : undefined;
|
||||
const shellType: string | undefined = Object.hasOwn(terminal.state, 'shell') ? terminal.state.shell as string : undefined;
|
||||
const terminalShellType = getTerminalShellType(shellType);
|
||||
if (!terminalShellType) {
|
||||
console.debug(`#terminalCompletions Shell type ${shellType} not supported`);
|
||||
|
||||
@@ -59,8 +59,8 @@ suite('PathExecutableCache', () => {
|
||||
symlinkDocRaw = resource.documentation;
|
||||
}
|
||||
}
|
||||
const realDoc = typeof realDocRaw === 'string' ? realDocRaw : (realDocRaw && 'value' in realDocRaw ? realDocRaw.value : undefined);
|
||||
const symlinkDoc = typeof symlinkDocRaw === 'string' ? symlinkDocRaw : (symlinkDocRaw && 'value' in symlinkDocRaw ? symlinkDocRaw.value : undefined);
|
||||
const realDoc = typeof realDocRaw === 'string' ? realDocRaw : (realDocRaw && Object.hasOwn(realDocRaw, 'value') ? realDocRaw.value : undefined);
|
||||
const symlinkDoc = typeof symlinkDocRaw === 'string' ? symlinkDocRaw : (symlinkDocRaw && Object.hasOwn(symlinkDocRaw, 'value') ? symlinkDocRaw.value : undefined);
|
||||
|
||||
const realPath = path.join(fixtureDir, 'real-executable.sh');
|
||||
const symlinkPath = path.join(fixtureDir, 'symlink-executable.sh');
|
||||
|
||||
Reference in New Issue
Block a user