Add more areas to strict null (#7243)

* add more areas to strict null

* fix compile errors

* fix tests

* fix checks

* address PR comments
This commit is contained in:
Anthony Dresser
2019-09-18 12:27:19 -07:00
committed by GitHub
parent 373828d76f
commit aad9c0f965
35 changed files with 193 additions and 184 deletions

View File

@@ -14,7 +14,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
export interface IComponent extends IDisposable {
descriptor: IComponentDescriptor;
modelStore: IModelStore;
layout();
layout(): void;
registerEventHandler(handler: (event: IComponentEventArgs) => void): IDisposable;
clearContainer?: () => void;
addToContainer?: (componentDescriptor: IComponentDescriptor, config: any, index?: number) => void;
@@ -76,7 +76,7 @@ export interface IModelStore {
* Creates and saves the reference of a component descriptor.
* This can be used during creation of a component later
*/
createComponentDescriptor(type: string, createComponentDescriptor): IComponentDescriptor;
createComponentDescriptor(type: string, createComponentDescriptor: string): IComponentDescriptor;
/**
* gets the descriptor for a previously created component ID
*/

View File

@@ -47,7 +47,7 @@ export function scriptSelect(connectionProfile: IConnectionProfile, metadata: az
connectionService.connectIfNotConnected(connectionProfile).then(connectionResult => {
let paramDetails: azdata.ScriptingParamDetails = getScriptingParamDetails(connectionService, connectionResult, metadata);
scriptingService.script(connectionResult, metadata, ScriptOperation.Select, paramDetails).then(result => {
if (result.script) {
if (result && result.script) {
queryEditorService.newSqlEditor(result.script).then((owner: IConnectableInput) => {
// Connect our editor to the input connection
let options: IConnectionCompletionOptions = {
@@ -82,7 +82,7 @@ export function scriptEditSelect(connectionProfile: IConnectionProfile, metadata
connectionService.connectIfNotConnected(connectionProfile).then(connectionResult => {
let paramDetails: azdata.ScriptingParamDetails = getScriptingParamDetails(connectionService, connectionResult, metadata);
scriptingService.script(connectionResult, metadata, ScriptOperation.Select, paramDetails).then(result => {
if (result.script) {
if (result && result.script) {
queryEditorService.newEditDataEditor(metadata.schema, metadata.name, result.script).then((owner: EditDataInput) => {
// Connect our editor
let options: IConnectionCompletionOptions = {

View File

@@ -26,7 +26,7 @@ export const Extensions = {
export interface IConnectionProviderRegistry {
registerConnectionProvider(id: string, properties: ConnectionProviderProperties): void;
getProperties(id: string): ConnectionProviderProperties;
getProperties(id: string): ConnectionProviderProperties | undefined;
readonly onNewProvider: Event<{ id: string, properties: ConnectionProviderProperties }>;
readonly providers: { [id: string]: ConnectionProviderProperties };
}
@@ -41,7 +41,7 @@ class ConnectionProviderRegistryImpl implements IConnectionProviderRegistry {
this._onNewProvider.fire({ id, properties });
}
public getProperties(id: string): ConnectionProviderProperties {
public getProperties(id: string): ConnectionProviderProperties | undefined {
return this._providers.get(id);
}

View File

@@ -257,7 +257,7 @@ class DataResourceDataProvider implements IGridDataProvider {
return serializer.handleSerialization(this.documentUri, format, (filePath) => this.doSerialize(serializer, filePath, format, selection));
}
private async doSerialize(serializer: ResultSerializer, filePath: string, format: SaveFormat, selection: Slick.Range[]): Promise<SaveResultsResponse> {
private doSerialize(serializer: ResultSerializer, filePath: string, format: SaveFormat, selection: Slick.Range[]): Promise<SaveResultsResponse | undefined> {
// TODO implement selection support
let columns = this.resultSet.columnInfo;
let rowLength = this.rows.length;
@@ -296,8 +296,7 @@ class DataResourceDataProvider implements IGridDataProvider {
getRowRange: (rowStart, numberOfRows) => getRows(rowStart, numberOfRows),
rowCount: rowLength
});
let result = await this._serializationService.serializeResults(serializeRequestParams);
return result;
return this._serializationService.serializeResults(serializeRequestParams);
}
/**

View File

@@ -32,7 +32,7 @@ let prevSavePath: string;
export interface SaveResultsResponse {
succeeded: boolean;
messages: string;
messages?: string;
}
interface ICsvConfig {
@@ -94,7 +94,7 @@ export class ResultSerializer {
/**
* Handle save request by getting filename from user and sending request to service
*/
public handleSerialization(uri: string, format: SaveFormat, sendRequest: ((filePath: string) => Promise<SaveResultsResponse>)): Thenable<void> {
public handleSerialization(uri: string, format: SaveFormat, sendRequest: ((filePath: string) => Promise<SaveResultsResponse | undefined>)): Thenable<void> {
const self = this;
return this.promptForFilepath(format, uri).then(filePath => {
if (filePath) {
@@ -103,7 +103,7 @@ export class ResultSerializer {
}
return self.doSave(filePath, format, () => sendRequest(filePath));
}
return Promise.resolve(undefined);
return Promise.resolve();
});
}
@@ -331,19 +331,19 @@ export class ResultSerializer {
/**
* Send request to sql tools service to save a result set
*/
private async doSave(filePath: string, format: string, sendRequest: () => Promise<SaveResultsResponse>): Promise<void> {
private async doSave(filePath: string, format: string, sendRequest: () => Promise<SaveResultsResponse | undefined>): Promise<void> {
this.logToOutputChannel(LocalizedConstants.msgSaveStarted + filePath);
// send message to the sqlserverclient for converting results to the requested format and saving to filepath
try {
let result = await sendRequest();
if (result.messages) {
if (!result || result.messages) {
this._notificationService.notify({
severity: Severity.Error,
message: LocalizedConstants.msgSaveFailed + result.messages
message: LocalizedConstants.msgSaveFailed + (result ? result.messages : '')
});
this.logToOutputChannel(LocalizedConstants.msgSaveFailed + result.messages);
this.logToOutputChannel(LocalizedConstants.msgSaveFailed + (result ? result.messages : ''));
} else {
this.promptFileSavedNotification(filePath);
this.logToOutputChannel(LocalizedConstants.msgSaveSucceeded + filePath);

View File

@@ -10,6 +10,6 @@ import { FileNode } from 'sql/workbench/services/fileBrowser/common/fileNode';
*/
export class FileBrowserTree {
public rootNode: FileNode;
public selectedNode: FileNode;
public selectedNode?: FileNode;
public expandedNodes: FileNode[];
}

View File

@@ -33,7 +33,7 @@ export class FileNode {
/**
* Parent node
*/
public parent: FileNode;
public parent?: FileNode;
/**
* Children nodes
@@ -55,7 +55,7 @@ export class FileNode {
*/
public hasChildren: boolean;
constructor(id: string, name: string, fullPath: string, isFile: boolean, isExpanded: boolean, ownerUri: string, parent: FileNode) {
constructor(id: string, name: string, fullPath: string, isFile: boolean, isExpanded: boolean, ownerUri: string, parent?: FileNode) {
if (id) {
this.id = id;
} else {
@@ -69,4 +69,4 @@ export class FileNode {
this.isExpanded = isExpanded;
this.parent = parent;
}
}
}