Fix unsafe type assertions on object literals (#213318)

This commit is contained in:
Martin Aeschlimann 2024-05-23 17:31:20 +02:00 committed by GitHub
parent 3eb20557bd
commit 343a048566
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 14 deletions

View file

@ -21,8 +21,8 @@ export type IStyleOverride<T> = {
[P in keyof T]?: ColorIdentifier | undefined;
};
function overrideStyles<T>(override: IStyleOverride<T>, styles: T): any {
const result = { ...styles } as { [P in keyof T]: string | undefined };
function overrideStyles<T extends { [P in keyof T]: string | undefined }>(override: IStyleOverride<T>, styles: T): any {
const result: { [P in keyof T]: string | undefined } = { ...styles };
for (const key in override) {
const val = override[key];
result[key] = val !== undefined ? asCssVariable(val) : undefined;

View file

@ -30,13 +30,13 @@ import { isString } from 'vs/base/common/types';
import { CharCode } from 'vs/base/common/charCode';
import { IExtensionManifest } from 'vs/platform/extensions/common/extensions';
const textMimeType = {
const textMimeType: { [ext: string]: string | undefined } = {
'.html': 'text/html',
'.js': 'text/javascript',
'.json': 'application/json',
'.css': 'text/css',
'.svg': 'image/svg+xml',
} as { [ext: string]: string | undefined };
};
/**
* Return an error to the client.
@ -306,17 +306,17 @@ export class WebClientServer {
scopes: [['user:email'], ['repo']]
} : undefined;
const productConfiguration = <Partial<IProductConfiguration>>{
const productConfiguration = {
embedderIdentifier: 'server-distro',
extensionsGallery: this._webExtensionResourceUrlTemplate ? {
extensionsGallery: this._webExtensionResourceUrlTemplate && this._productService.extensionsGallery ? {
...this._productService.extensionsGallery,
'resourceUrlTemplate': this._webExtensionResourceUrlTemplate.with({
resourceUrlTemplate: this._webExtensionResourceUrlTemplate.with({
scheme: 'http',
authority: remoteAuthority,
path: `${this._webExtensionRoute}/${this._webExtensionResourceUrlTemplate.authority}${this._webExtensionResourceUrlTemplate.path}`
}).toString(true)
} : undefined
};
} satisfies Partial<IProductConfiguration>;
if (!this._environmentService.isBuilt) {
try {

View file

@ -815,18 +815,18 @@ registerAction2(class extends Action2 {
});
const ThemesSubMenu = new MenuId('ThemesSubMenu');
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, <ISubmenuItem>{
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
title: localize('themes', "Themes"),
submenu: ThemesSubMenu,
group: '2_configuration',
order: 7
});
MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, <ISubmenuItem>{
} satisfies ISubmenuItem);
MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
title: localize({ key: 'miSelectTheme', comment: ['&& denotes a mnemonic'] }, "&&Theme"),
submenu: ThemesSubMenu,
group: '2_configuration',
order: 7
});
} satisfies ISubmenuItem);
MenuRegistry.appendMenuItem(ThemesSubMenu, {
command: {

View file

@ -437,7 +437,7 @@ export class ColorThemeData implements IWorkbenchColorTheme {
}
public getThemeSpecificColors(colors: IThemeScopableCustomizations): IThemeScopedCustomizations | undefined {
let themeSpecificColors;
let themeSpecificColors: IThemeScopedCustomizations | undefined;
for (const key in colors) {
const scopedColors = colors[key];
if (this.isThemeScope(key) && scopedColors instanceof Object && !Array.isArray(scopedColors)) {
@ -446,7 +446,7 @@ export class ColorThemeData implements IWorkbenchColorTheme {
const themeId = themeScope.substring(1, themeScope.length - 1);
if (this.isThemeScopeMatch(themeId)) {
if (!themeSpecificColors) {
themeSpecificColors = {} as IThemeScopedCustomizations;
themeSpecificColors = {};
}
const scopedThemeSpecificColors = scopedColors as IThemeScopedCustomizations;
for (const subkey in scopedThemeSpecificColors) {