Skip to content

Commit

Permalink
Fix unsafe type assertions on object literals (#213318)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli authored May 23, 2024
1 parent 3eb2055 commit 343a048
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/vs/platform/theme/browser/defaultStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/vs/server/node/webClientServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/services/themes/common/colorThemeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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) {
Expand Down

0 comments on commit 343a048

Please sign in to comment.