Enable strict null in MSSQL extension (#22433)

This commit is contained in:
Charles Gagnon
2023-03-23 16:49:48 -07:00
committed by GitHub
parent 59ad572800
commit dfc6469c9d
6 changed files with 19 additions and 11 deletions

View File

@@ -8,9 +8,14 @@ import { Credential } from 'azdata';
// --------------------------------- < Read Credential Request > -------------------------------------------------
// We don't need to include the actual password field when making read/delete requests, so for now just
// creating a custom type here to avoid issues with strict null checking until we can get STS updated
// to expect just the ID itself instead of the full credential object type
export type CredentialId = Omit<Credential, 'password'>;
// Read Credential request message callback declaration
export namespace ReadCredentialRequest {
export const type = new RequestType<Credential, Credential, void, void>('credential/read');
export const type = new RequestType<CredentialId, Credential, void, void>('credential/read');
}
// --------------------------------- </ Read Credential Request > -------------------------------------------------
@@ -28,6 +33,6 @@ export namespace SaveCredentialRequest {
// Delete Credential request message callback declaration
export namespace DeleteCredentialRequest {
export const type = new RequestType<Credential, boolean, void, void>('credential/delete');
export const type = new RequestType<CredentialId, boolean, void, void>('credential/delete');
}
// --------------------------------- </ Delete Credential Request > -------------------------------------------------

View File

@@ -47,10 +47,10 @@ export class SqlCredentialService extends SqlOpsFeature<any> {
const password = await this._secretStorage.get(credentialId);
return {
credentialId: credentialId,
password: password
password: password || ''
};
}
return this._client.sendRequest(Contracts.ReadCredentialRequest.type, { credentialId, password: undefined });
return this._client.sendRequest(Contracts.ReadCredentialRequest.type, { credentialId });
};
let saveCredential = async (credentialId: string, password: string): Promise<boolean> => {
@@ -70,7 +70,7 @@ export class SqlCredentialService extends SqlOpsFeature<any> {
console.log('credential does not exist in native secret store');
}
}
return this._client.sendRequest(Contracts.DeleteCredentialRequest.type, { credentialId, password: undefined });
return this._client.sendRequest(Contracts.DeleteCredentialRequest.type, { credentialId });
};
return azdata.credentials.registerProvider({
@@ -87,7 +87,11 @@ export class SqlCredentialService extends SqlOpsFeature<any> {
initialize(capabilities: ServerCapabilities): void { }
protected registerProvider(options: any): Disposable { return undefined; }
protected registerProvider(options: any): Disposable {
return {
dispose: () => { }
}
}
private constructor(context: AppContext, protected readonly client: SqlOpsDataClient) {
super(client, SqlCredentialService.messagesTypes);

View File

@@ -128,7 +128,7 @@ export class AccountFeature implements StaticFeature {
}
let params: contracts.TokenRefreshedParams = {
token: securityToken.token,
expiresOn: securityToken.expiresOn,
expiresOn: securityToken.expiresOn!,
uri: request.uri
};

View File

@@ -102,7 +102,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
}
protected get objectInfo(): ObjectInfoType {
return this._viewInfo?.objectInfo;
return this._viewInfo.objectInfo;
}
protected get originalObjectInfo(): ObjectInfoType {

View File

@@ -7,7 +7,7 @@ export class DataItemCache<T> {
millisecondsToLive: number;
getValueFunction: (...args: any[]) => Promise<T>;
cachedItem: T;
cachedItem: T | undefined;
fetchDate: Date;
constructor(getValueFunction: (...args: any[]) => Promise<T>, secondsToLive: number) {

View File

@@ -3,8 +3,7 @@
"compilerOptions": {
"outDir": "./out",
"strict": false,
"noUnusedParameters": false,
"strictNullChecks": false
"noUnusedParameters": false
},
"include": [
"src/**/*"