From 82e9561f169114b81c5d0d785f439d4a0d7fd8bd Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 16 Jan 2019 11:26:24 -0800 Subject: [PATCH] Strict null checks --- src/tsconfig.strictNullChecks.json | 8 ++++++++ src/vs/editor/standalone/browser/standaloneEditor.ts | 7 ++++--- src/vs/editor/standalone/browser/standaloneLanguages.ts | 4 ++-- .../api/browser/viewsContainersExtensionPoint.ts | 2 +- .../browser/parts/notifications/notificationsCommands.ts | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index 5b05fc4c7e5..6db7c93c154 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -256,6 +256,7 @@ "./vs/editor/contrib/wordPartOperations/test/wordPartOperations.test.ts", "./vs/editor/contrib/wordPartOperations/wordPartOperations.ts", "./vs/editor/contrib/zoneWidget/zoneWidget.ts", + "./vs/editor/editor.api.ts", "./vs/editor/editor.worker.ts", "./vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts", "./vs/editor/standalone/browser/colorizer.ts", @@ -264,6 +265,8 @@ "./vs/editor/standalone/browser/simpleServices.ts", "./vs/editor/standalone/browser/standaloneCodeEditor.ts", "./vs/editor/standalone/browser/standaloneCodeServiceImpl.ts", + "./vs/editor/standalone/browser/standaloneEditor.ts", + "./vs/editor/standalone/browser/standaloneLanguages.ts", "./vs/editor/standalone/browser/standaloneServices.ts", "./vs/editor/standalone/browser/standaloneThemeServiceImpl.ts", "./vs/editor/standalone/browser/toggleHighContrast/toggleHighContrast.ts", @@ -274,6 +277,7 @@ "./vs/editor/standalone/common/standaloneThemeService.ts", "./vs/editor/standalone/common/themes.ts", "./vs/editor/standalone/test/browser/simpleServices.test.ts", + "./vs/editor/standalone/test/browser/standaloneLanguages.test.ts", "./vs/editor/test/browser/controller/imeTester.ts", "./vs/editor/test/browser/editorTestServices.ts", "./vs/editor/test/browser/testCodeEditor.ts", @@ -508,6 +512,7 @@ "./vs/platform/workspaces/node/workspacesIpc.ts", "./vs/vscode.d.ts", "./vs/vscode.proposed.d.ts", + "./vs/workbench/api/browser/viewsContainersExtensionPoint.ts", "./vs/workbench/api/node/extHostExtensionActivator.ts", "./vs/workbench/api/node/extHostSearch.fileIndex.ts", "./vs/workbench/api/node/extHostTypes.ts", @@ -539,7 +544,10 @@ "./vs/workbench/browser/parts/editor/resourceViewer.ts", "./vs/workbench/browser/parts/editor/sideBySideEditor.ts", "./vs/workbench/browser/parts/editor/textEditor.ts", + "./vs/workbench/browser/parts/notifications/notificationsActions.ts", "./vs/workbench/browser/parts/notifications/notificationsAlerts.ts", + "./vs/workbench/browser/parts/notifications/notificationsCommands.ts", + "./vs/workbench/browser/parts/notifications/notificationsStatus.ts", "./vs/workbench/browser/parts/quickinput/quickInputBox.ts", "./vs/workbench/browser/parts/quickinput/quickInputUtils.ts", "./vs/workbench/browser/parts/quickopen/quickopen.ts", diff --git a/src/vs/editor/standalone/browser/standaloneEditor.ts b/src/vs/editor/standalone/browser/standaloneEditor.ts index 638277b52d2..30ecaf3b7d9 100644 --- a/src/vs/editor/standalone/browser/standaloneEditor.ts +++ b/src/vs/editor/standalone/browser/standaloneEditor.ts @@ -37,6 +37,8 @@ import { IMarker, IMarkerData } from 'vs/platform/markers/common/markers'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IOpenerService } from 'vs/platform/opener/common/opener'; +type Omit = Pick>; + function withAllStandaloneServices(domElement: HTMLElement, override: IEditorOverrideServices, callback: (services: DynamicStandaloneServices) => T): T { let services = new DynamicStandaloneServices(domElement, override); @@ -260,15 +262,14 @@ export function colorizeModelLine(model: ITextModel, lineNumber: number, tabSize /** * @internal */ -function getSafeTokenizationSupport(language: string): modes.ITokenizationSupport { +function getSafeTokenizationSupport(language: string): Omit { let tokenizationSupport = modes.TokenizationRegistry.get(language); if (tokenizationSupport) { return tokenizationSupport; } return { getInitialState: () => NULL_STATE, - tokenize: (line: string, state: modes.IState, deltaOffset: number) => nullTokenize(language, line, state, deltaOffset), - tokenize2: undefined, + tokenize: (line: string, state: modes.IState, deltaOffset: number) => nullTokenize(language, line, state, deltaOffset) }; } diff --git a/src/vs/editor/standalone/browser/standaloneLanguages.ts b/src/vs/editor/standalone/browser/standaloneLanguages.ts index e5ffa21d894..238ae5df16e 100644 --- a/src/vs/editor/standalone/browser/standaloneLanguages.ts +++ b/src/vs/editor/standalone/browser/standaloneLanguages.ts @@ -345,10 +345,10 @@ export function registerSignatureHelpProvider(languageId: string, provider: mode */ export function registerHoverProvider(languageId: string, provider: modes.HoverProvider): IDisposable { return modes.HoverProviderRegistry.register(languageId, { - provideHover: (model: model.ITextModel, position: Position, token: CancellationToken): Promise => { + provideHover: (model: model.ITextModel, position: Position, token: CancellationToken): Promise => { let word = model.getWordAtPosition(position); - return Promise.resolve(provider.provideHover(model, position, token)).then((value) => { + return Promise.resolve(provider.provideHover(model, position, token)).then((value): modes.Hover | undefined => { if (!value) { return undefined; } diff --git a/src/vs/workbench/api/browser/viewsContainersExtensionPoint.ts b/src/vs/workbench/api/browser/viewsContainersExtensionPoint.ts index 0e24d882303..b732ccd81d6 100644 --- a/src/vs/workbench/api/browser/viewsContainersExtensionPoint.ts +++ b/src/vs/workbench/api/browser/viewsContainersExtensionPoint.ts @@ -153,7 +153,7 @@ class ViewsContainersExtensionHandler implements IWorkbenchContribution { return order; } - private registerCustomViewlet(descriptor: IUserFriendlyViewsContainerDescriptor2, order: number, cssClass: string, extensionId: ExtensionIdentifier): void { + private registerCustomViewlet(descriptor: IUserFriendlyViewsContainerDescriptor2, order: number, cssClass: string, extensionId: ExtensionIdentifier | undefined): void { const viewContainersRegistry = Registry.as(ViewContainerExtensions.ViewContainersRegistry); const viewletRegistry = Registry.as(ViewletExtensions.Viewlets); const id = descriptor.id; diff --git a/src/vs/workbench/browser/parts/notifications/notificationsCommands.ts b/src/vs/workbench/browser/parts/notifications/notificationsCommands.ts index 1f5f7050de4..016b50dc100 100644 --- a/src/vs/workbench/browser/parts/notifications/notificationsCommands.ts +++ b/src/vs/workbench/browser/parts/notifications/notificationsCommands.ts @@ -62,7 +62,7 @@ export interface INotificationsToastController { export function registerNotificationCommands(center: INotificationsCenterController, toasts: INotificationsToastController): void { - function getNotificationFromContext(listService: IListService, context?: any): INotificationViewItem { + function getNotificationFromContext(listService: IListService, context?: any): INotificationViewItem | undefined { if (isNotificationViewItem(context)) { return context; } -- GitLab