Clean up few more calls to object.freeze

- Fixed explicit casts hiding some type errors on object passed to `object.freeze` (too many properties or missing properties)
- Remove some extra casts
- Fixed casts of `Object.freeze` removing readonly
This commit is contained in:
Matt Bierner
2022-03-16 15:59:53 -07:00
parent 7ba9564ac6
commit 342e05815a
8 changed files with 13 additions and 11 deletions

View File

@@ -277,7 +277,7 @@ export class ExtHostConfigProvider {
mixin(result, config, false);
}
return <vscode.WorkspaceConfiguration>Object.freeze(result);
return Object.freeze(result);
}
private _toReadonlyValue(result: any): any {

View File

@@ -191,7 +191,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
this._checkDisposed();
const result = this.#data.get(uri);
if (Array.isArray(result)) {
return <ReadonlyArray<vscode.Diagnostic>>Object.freeze(result.slice(0));
return Object.freeze(result.slice(0));
}
return [];
}

View File

@@ -106,7 +106,7 @@ export class ExtHostDocumentSaveParticipant implements ExtHostDocumentSavePartic
const { document, reason } = stubEvent;
const { version } = document;
const event = Object.freeze(<vscode.TextDocumentWillSaveEvent>{
const event = Object.freeze<vscode.TextDocumentWillSaveEvent>({
document,
reason,
waitUntil(p: Promise<any | vscode.TextEdit[]>) {