Skip to content

Commit cb4b80b

Browse files
committed
Fixing strict null errors in extHostApiImpl
1 parent 02468f9 commit cb4b80b

5 files changed

Lines changed: 15 additions & 12 deletions

File tree

src/vs/workbench/api/node/extHost.api.impl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ export function createApiFactory(
647647
// namespace: scm
648648
const scm: typeof vscode.scm = {
649649
get inputBox() {
650-
return extHostSCM.getLastInputBox(extension);
650+
return extHostSCM.getLastInputBox(extension)!; // Strict null override - Deprecated api
651651
},
652652
createSourceControl(id: string, label: string, rootUri?: vscode.Uri) {
653653
return extHostSCM.createSourceControl(extension, id, label, rootUri);
@@ -859,7 +859,7 @@ class Extension<T> implements vscode.Extension<T> {
859859

860860
get exports(): T {
861861
if (this.packageJSON.api === 'none') {
862-
return undefined;
862+
return undefined!; // Strict nulloverride - Public api
863863
}
864864
return <T>this._extensionService.getExtensionExports(this._identifier);
865865
}

src/vs/workbench/api/node/extHost.protocol.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ export interface ExtHostUrlsShape {
527527
}
528528

529529
export interface MainThreadWorkspaceShape extends IDisposable {
530-
$startFileSearch(includePattern: string | undefined, includeFolder: UriComponents | undefined, excludePatternOrDisregardExcludes: string | false | undefined, maxResults: number, token: CancellationToken): Promise<UriComponents[] | undefined>;
530+
$startFileSearch(includePattern: string | undefined, includeFolder: UriComponents | undefined, excludePatternOrDisregardExcludes: string | false | undefined, maxResults: number | undefined, token: CancellationToken): Promise<UriComponents[] | undefined>;
531531
$startTextSearch(query: IPatternInfo, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<vscode.TextSearchComplete>;
532532
$checkExists(includes: string[], token: CancellationToken): Promise<boolean>;
533533
$saveAll(includeUntitled?: boolean): Promise<boolean>;
@@ -1105,19 +1105,19 @@ export interface ExtHostProgressShape {
11051105

11061106
export interface ExtHostCommentsShape {
11071107
$provideDocumentComments(handle: number, document: UriComponents): Promise<modes.CommentInfo>;
1108-
$createNewCommentThread(handle: number, document: UriComponents, range: IRange, text: string): Promise<modes.CommentThread>;
1108+
$createNewCommentThread(handle: number, document: UriComponents, range: IRange, text: string): Promise<modes.CommentThread | null>;
11091109
$onCommentWidgetInputChange(commentControllerHandle: number, input: string): Promise<number | undefined>;
11101110
$provideCommentingRanges(commentControllerHandle: number, uriComponents: UriComponents, token: CancellationToken): Promise<IRange[] | undefined>;
11111111
$createNewCommentWidgetCallback(commentControllerHandle: number, uriComponents: UriComponents, range: IRange, token: CancellationToken): void;
1112-
$replyToCommentThread(handle: number, document: UriComponents, range: IRange, commentThread: modes.CommentThread, text: string): Promise<modes.CommentThread>;
1112+
$replyToCommentThread(handle: number, document: UriComponents, range: IRange, commentThread: modes.CommentThread, text: string): Promise<modes.CommentThread | null>;
11131113
$editComment(handle: number, document: UriComponents, comment: modes.Comment, text: string): Promise<void>;
11141114
$deleteComment(handle: number, document: UriComponents, comment: modes.Comment): Promise<void>;
11151115
$startDraft(handle: number, document: UriComponents): Promise<void>;
11161116
$deleteDraft(handle: number, document: UriComponents): Promise<void>;
11171117
$finishDraft(handle: number, document: UriComponents): Promise<void>;
11181118
$addReaction(handle: number, document: UriComponents, comment: modes.Comment, reaction: modes.CommentReaction): Promise<void>;
11191119
$deleteReaction(handle: number, document: UriComponents, comment: modes.Comment, reaction: modes.CommentReaction): Promise<void>;
1120-
$provideWorkspaceComments(handle: number): Promise<modes.CommentThread[]>;
1120+
$provideWorkspaceComments(handle: number): Promise<modes.CommentThread[] | null>;
11211121
}
11221122

11231123
export interface ExtHostStorageShape {

src/vs/workbench/api/node/extHostTypeConverters.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,10 @@ export namespace TextEditorOptions {
960960

961961
export namespace GlobPattern {
962962

963-
export function from(pattern: vscode.GlobPattern): string | types.RelativePattern {
963+
export function from(pattern: vscode.GlobPattern): string | types.RelativePattern;
964+
export function from(pattern: undefined | null): undefined | null;
965+
export function from(pattern: vscode.GlobPattern | undefined | null): string | types.RelativePattern | undefined | null;
966+
export function from(pattern: vscode.GlobPattern | undefined | null): string | types.RelativePattern | undefined | null {
964967
if (pattern instanceof types.RelativePattern) {
965968
return pattern;
966969
}

src/vs/workbench/api/node/extHostWorkspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac
389389

390390
// --- search ---
391391

392-
findFiles(include: string | RelativePattern, exclude: vscode.GlobPattern, maxResults: number, extensionId: ExtensionIdentifier, token: vscode.CancellationToken = CancellationToken.None): Promise<vscode.Uri[]> {
392+
findFiles(include: string | RelativePattern | undefined | null, exclude: vscode.GlobPattern | undefined | null, maxResults: number | undefined, extensionId: ExtensionIdentifier, token: vscode.CancellationToken = CancellationToken.None): Promise<vscode.Uri[]> {
393393
this._logService.trace(`extHostWorkspace#findFiles: fileSearch, extension: ${extensionId.value}, entryPoint: findFiles`);
394394

395395
let includePattern: string | undefined;

src/vs/workbench/contrib/preferences/electron-browser/preferences.contribution.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ interface ISerializedPreferencesEditorInput {
8888
// Register Preferences Editor Input Factory
8989
class PreferencesEditorInputFactory implements IEditorInputFactory {
9090

91-
serialize(editorInput: EditorInput): string {
91+
serialize(editorInput: EditorInput): string | null {
9292
const input = <PreferencesEditorInput>editorInput;
9393

9494
if (input.details && input.master) {
@@ -116,7 +116,7 @@ class PreferencesEditorInputFactory implements IEditorInputFactory {
116116
return null;
117117
}
118118

119-
deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput {
119+
deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput | null {
120120
const deserialized: ISerializedPreferencesEditorInput = JSON.parse(serializedEditorInput);
121121

122122
const registry = Registry.as<IEditorInputFactoryRegistry>(EditorInputExtensions.EditorInputFactories);
@@ -555,7 +555,7 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
555555

556556
abstract class SettingsCommand extends Command {
557557

558-
protected getPreferencesEditor(accessor: ServicesAccessor): PreferencesEditor | SettingsEditor2 {
558+
protected getPreferencesEditor(accessor: ServicesAccessor): PreferencesEditor | SettingsEditor2 | null {
559559
const activeControl = accessor.get(IEditorService).activeControl;
560560
if (activeControl instanceof PreferencesEditor || activeControl instanceof SettingsEditor2) {
561561
return activeControl;
@@ -603,7 +603,7 @@ class FocusSettingsFileEditorCommand extends SettingsCommand {
603603
const preferencesEditor = this.getPreferencesEditor(accessor);
604604
if (preferencesEditor instanceof PreferencesEditor) {
605605
preferencesEditor.focusSettingsFileEditor();
606-
} else {
606+
} else if (preferencesEditor) {
607607
preferencesEditor.focusSettings();
608608
}
609609
}

0 commit comments

Comments
 (0)