Skip to content

Commit

Permalink
Fix a few more simple unsafe type assertions (#211879)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed May 2, 2024
1 parent 961d4ad commit e124c26
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/grid/gridview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,7 @@ export class GridView implements IDisposable {
return {
node: this._deserializeNode(serializedChild, orthogonal(orientation), deserializer, node.size),
visible: (serializedChild as { visible?: boolean }).visible
} as INodeDescriptor;
} satisfies INodeDescriptor;
});

result = new BranchNode(orientation, this.layoutController, this.styles, this.proportionalLayout, node.size, orthogonalSize, undefined, children);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/splitview/splitview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ export class SplitView<TLayoutContext = undefined, TView extends IView<TLayoutCo
if (options.descriptor) {
this.size = options.descriptor.size;
options.descriptor.views.forEach((viewDescriptor, index) => {
const sizing = types.isUndefined(viewDescriptor.visible) || viewDescriptor.visible ? viewDescriptor.size : { type: 'invisible', cachedVisibleSize: viewDescriptor.size } as InvisibleSizing;
const sizing = types.isUndefined(viewDescriptor.visible) || viewDescriptor.visible ? viewDescriptor.size : { type: 'invisible', cachedVisibleSize: viewDescriptor.size } satisfies InvisibleSizing;

const view = viewDescriptor.view;
this.doAddView(view, sizing, index, true);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/tree/asyncDataTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable

this.root.element = input!;

const viewStateContext = viewState && { viewState, focus: [], selection: [] } as IAsyncDataTreeViewStateContext<TInput, T>;
const viewStateContext: IAsyncDataTreeViewStateContext<TInput, T> | undefined = viewState && { viewState, focus: [], selection: [] };

await this._updateChildren(input, true, false, viewStateContext);

Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/tree/objectTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class CompressibleStickyScrollDelegate<T, TFilterData> implements IStickyScrollD
// Compress the elements
const lastStickyNode = stickyNodes[stickyNodes.length - 1];
const compressedElement: ICompressedTreeNode<T> = { elements, incompressible: false };
const compressedNode = { ...lastStickyNode.node, children: [], element: compressedElement } as ITreeNode<ICompressedTreeNode<T>, TFilterData>;
const compressedNode: ITreeNode<ICompressedTreeNode<T>, TFilterData> = { ...lastStickyNode.node, children: [], element: compressedElement };

const stickyTreeNode = new Proxy(stickyNodes[0].node, {});

Expand Down
4 changes: 2 additions & 2 deletions src/vs/base/common/processes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ export interface ProcessItem {
* Sanitizes a VS Code process environment by removing all Electron/VS Code-related values.
*/
export function sanitizeProcessEnvironment(env: IProcessEnvironment, ...preserve: string[]): void {
const set = preserve.reduce((set, key) => {
const set = preserve.reduce<Record<string, boolean>>((set, key) => {
set[key] = true;
return set;
}, {} as Record<string, boolean>);
}, {});
const keysToRemove = [
/^ELECTRON_.+$/,
/^VSCODE_(?!(PORTABLE|SHELL_LOGIN|ENV_REPLACE|ENV_APPEND|ENV_PREPEND)).+$/,
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/contrib/folding/browser/folding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ class FoldRangeFromSelectionAction extends FoldingAction<void> {
--endLineNumber;
}
if (endLineNumber > selection.startLineNumber) {
collapseRanges.push(<FoldRange>{
collapseRanges.push({
startLineNumber: selection.startLineNumber,
endLineNumber: endLineNumber,
type: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class StorageManager extends Disposable {
}

set(key: string, value: IExtensionIdentifier[], scope: StorageScope): void {
const newValue: string = JSON.stringify(value.map(({ id, uuid }) => (<IExtensionIdentifier>{ id, uuid })));
const newValue: string = JSON.stringify(value.map(({ id, uuid }): IExtensionIdentifier => ({ id, uuid })));
const oldValue = this._get(key, scope);
if (oldValue !== newValue) {
if (scope === StorageScope.PROFILE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ function setTelemetry(extension: IGalleryExtension, index: number, querySource?:

function toExtension(galleryExtension: IRawGalleryExtension, version: IRawGalleryExtensionVersion, allTargetPlatforms: TargetPlatform[], queryContext?: IStringDictionary<any>): IGalleryExtension {
const latestVersion = galleryExtension.versions[0];
const assets = <IGalleryExtensionAssets>{
const assets: IGalleryExtensionAssets = {
manifest: getVersionAsset(version, AssetType.Manifest),
readme: getVersionAsset(version, AssetType.Details),
changelog: getVersionAsset(version, AssetType.Changelog),
Expand Down Expand Up @@ -799,7 +799,7 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
return extensions;
};

return { firstPage: extensions, total, pageSize: query.pageSize, getPage } as IPager<IGalleryExtension>;
return { firstPage: extensions, total, pageSize: query.pageSize, getPage };
}

private async queryGalleryExtensions(query: Query, criteria: IExtensionCriteria, token: CancellationToken): Promise<{ extensions: IGalleryExtension[]; total: number }> {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHostTypeConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ export namespace DecorationRenderOptions {
export namespace TextEdit {

export function from(edit: vscode.TextEdit): languages.TextEdit {
return <languages.TextEdit>{
return {
text: edit.newText,
eol: edit.newEol && EndOfLine.from(edit.newEol),
range: Range.from(edit.range)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ export class FileBasedRecommendations extends ExtensionRecommendations {
private getCachedRecommendations(): IStringDictionary<number> {
let storedRecommendations = JSON.parse(this.storageService.get(recommendationsStorageKey, StorageScope.PROFILE, '[]'));
if (Array.isArray(storedRecommendations)) {
storedRecommendations = storedRecommendations.reduce((result, id) => { result[id] = Date.now(); return result; }, <IStringDictionary<number>>{});
storedRecommendations = storedRecommendations.reduce<IStringDictionary<number>>((result, id) => { result[id] = Date.now(); return result; }, {});
}
const result: IStringDictionary<number> = {};
Object.entries(storedRecommendations).forEach(([key, value]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class WebRecommendations extends ExtensionRecommendations {
protected async doActivate(): Promise<void> {
const isOnlyWeb = this.extensionManagementServerService.webExtensionManagementServer && !this.extensionManagementServerService.localExtensionManagementServer && !this.extensionManagementServerService.remoteExtensionManagementServer;
if (isOnlyWeb && Array.isArray(this.productService.webExtensionTips)) {
this._recommendations = this.productService.webExtensionTips.map(extensionId => (<ExtensionRecommendation>{
this._recommendations = this.productService.webExtensionTips.map((extensionId): ExtensionRecommendation => ({
extension: extensionId.toLowerCase(),
reason: {
reasonId: ExtensionRecommendationReason.Application,
Expand All @@ -33,6 +33,5 @@ export class WebRecommendations extends ExtensionRecommendations {
}));
}
}

}

4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/webview/browser/themeing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ export class WebviewThemeDataProvider extends Disposable {
const editorFontSize = configuration.fontSize || EDITOR_FONT_DEFAULTS.fontSize;

const theme = this._themeService.getColorTheme();
const exportedColors = colorRegistry.getColorRegistry().getColors().reduce((colors, entry) => {
const exportedColors = colorRegistry.getColorRegistry().getColors().reduce<Record<string, string>>((colors, entry) => {
const color = theme.getColor(entry.id);
if (color) {
colors['vscode-' + entry.id.replace('.', '-')] = color.toString();
}
return colors;
}, {} as { [key: string]: string });
}, {});

const styles = {
'vscode-font-family': DEFAULT_FONT_FAMILY,
Expand Down

0 comments on commit e124c26

Please sign in to comment.