mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Enable strictNullChecks for extensions by default (#19197)
* Strict null on extensions * fix test * Fail on no stdin
This commit is contained in:
@@ -82,6 +82,7 @@ async function handleLaunchSsmsMinGswDialogCommand(connectionContext?: azdata.Ob
|
|||||||
if (!connectionContext) {
|
if (!connectionContext) {
|
||||||
TelemetryReporter.sendErrorEvent(TelemetryViews.SsmsMinGsw, 'NoConnectionContext');
|
TelemetryReporter.sendErrorEvent(TelemetryViews.SsmsMinGsw, 'NoConnectionContext');
|
||||||
void vscode.window.showErrorMessage(localize('adminToolExtWin.noConnectionContextForGsw', "No ConnectionContext provided for handleLaunchSsmsMinPropertiesDialogCommand"));
|
void vscode.window.showErrorMessage(localize('adminToolExtWin.noConnectionContextForGsw', "No ConnectionContext provided for handleLaunchSsmsMinPropertiesDialogCommand"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return launchSsmsDialog(
|
return launchSsmsDialog(
|
||||||
@@ -101,7 +102,7 @@ async function launchSsmsDialog(action: string, connectionContext: azdata.Object
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let oeNode: azdata.objectexplorer.ObjectExplorerNode;
|
let oeNode: azdata.objectexplorer.ObjectExplorerNode | undefined;
|
||||||
// Server node is a Connection node and so doesn't have the NodeInfo
|
// Server node is a Connection node and so doesn't have the NodeInfo
|
||||||
if (connectionContext.isConnectionNode) {
|
if (connectionContext.isConnectionNode) {
|
||||||
oeNode = undefined;
|
oeNode = undefined;
|
||||||
@@ -153,11 +154,11 @@ async function launchSsmsDialog(action: string, connectionContext: azdata.Object
|
|||||||
// Process has exited so remove from map of running processes
|
// Process has exited so remove from map of running processes
|
||||||
runningProcesses.delete(proc.pid);
|
runningProcesses.delete(proc.pid);
|
||||||
const err = stderr.toString();
|
const err = stderr.toString();
|
||||||
if ((execException && execException.code !== 0) || err !== '') {
|
if ((execException?.code !== 0) || err !== '') {
|
||||||
TelemetryReporter.sendErrorEvent(
|
TelemetryReporter.sendErrorEvent(
|
||||||
TelemetryViews.SsmsMinDialog,
|
TelemetryViews.SsmsMinDialog,
|
||||||
'LaunchSsmsDialogError',
|
'LaunchSsmsDialogError',
|
||||||
execException ? execException.code.toString() : '',
|
execException ? execException?.code?.toString() : '',
|
||||||
getTelemetryErrorType(err));
|
getTelemetryErrorType(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +171,7 @@ async function launchSsmsDialog(action: string, connectionContext: azdata.Object
|
|||||||
|
|
||||||
// If we're not using AAD the tool prompts for a password on stdin
|
// If we're not using AAD the tool prompts for a password on stdin
|
||||||
if (params.useAad !== true) {
|
if (params.useAad !== true) {
|
||||||
proc.stdin.end(password ? password : '');
|
proc.stdin!.end(password ? password : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the process into our map so we can make sure to stop them if we exit before shutting down
|
// Save the process into our map so we can make sure to stop them if we exit before shutting down
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ import * as vscode from 'vscode';
|
|||||||
|
|
||||||
describe('Extension activate test', () => {
|
describe('Extension activate test', () => {
|
||||||
it('Extension should activate correctly', async function (): Promise<void> {
|
it('Extension should activate correctly', async function (): Promise<void> {
|
||||||
await vscode.extensions.getExtension('Microsoft.admin-tool-ext-win').activate();
|
await vscode.extensions.getExtension('Microsoft.admin-tool-ext-win')!.activate();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import * as vscode from 'vscode';
|
|||||||
*/
|
*/
|
||||||
export class ExtHostObjectExplorerNodeStub implements azdata.objectexplorer.ObjectExplorerNode {
|
export class ExtHostObjectExplorerNodeStub implements azdata.objectexplorer.ObjectExplorerNode {
|
||||||
// Stub properties
|
// Stub properties
|
||||||
private parent: azdata.objectexplorer.ObjectExplorerNode;
|
private parent: azdata.objectexplorer.ObjectExplorerNode | undefined;
|
||||||
|
|
||||||
// Base properties
|
// Base properties
|
||||||
public connectionId: string;
|
public connectionId: string;
|
||||||
@@ -24,10 +24,10 @@ export class ExtHostObjectExplorerNodeStub implements azdata.objectexplorer.Obje
|
|||||||
public metadata: azdata.ObjectMetadata;
|
public metadata: azdata.ObjectMetadata;
|
||||||
public errorMessage: string;
|
public errorMessage: string;
|
||||||
|
|
||||||
constructor(nodeName: string, nodeSchema: string, nodeType: string, parent: azdata.objectexplorer.ObjectExplorerNode) {
|
constructor(nodeName: string, nodeSchema: string, nodeType: string, parent?: azdata.objectexplorer.ObjectExplorerNode) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.nodeType = nodeType;
|
this.nodeType = nodeType;
|
||||||
this.metadata = { metadataType: undefined, metadataTypeName: undefined, name: nodeName, schema: nodeSchema, urn: undefined, parentName: undefined, parentTypeName: undefined };
|
this.metadata = { metadataType: azdata.MetadataType.Table, metadataTypeName: 'MyMetadataTypeName', name: nodeName, schema: nodeSchema, urn: 'urn', parentName: undefined, parentTypeName: undefined };
|
||||||
}
|
}
|
||||||
|
|
||||||
isExpanded(): Thenable<boolean> {
|
isExpanded(): Thenable<boolean> {
|
||||||
@@ -38,7 +38,7 @@ export class ExtHostObjectExplorerNodeStub implements azdata.objectexplorer.Obje
|
|||||||
throw new Error('Method not implemented');
|
throw new Error('Method not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
setSelected(selected: boolean, clearOtherSelections: boolean = undefined): Thenable<void> {
|
setSelected(selected: boolean, clearOtherSelections: boolean): Thenable<void> {
|
||||||
throw new Error('Method not implemented');
|
throw new Error('Method not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,14 +77,14 @@ describe('buildUrn Method Tests', () => {
|
|||||||
|
|
||||||
it('Urn should be correct with Server and only Databases folder', async function (): Promise<void> {
|
it('Urn should be correct with Server and only Databases folder', async function (): Promise<void> {
|
||||||
const leafNode: ExtHostObjectExplorerNodeStub =
|
const leafNode: ExtHostObjectExplorerNodeStub =
|
||||||
new ExtHostObjectExplorerNodeStub('MyServer', undefined, 'Server', undefined)
|
new ExtHostObjectExplorerNodeStub('MyServer', 'MySchema', 'Server', undefined)
|
||||||
.createChild('Databases', undefined, 'Folder');
|
.createChild('Databases', '', 'Folder');
|
||||||
should(await buildUrn(leafNode)).equal('Server');
|
should(await buildUrn(leafNode)).equal('Server');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Urn should be correct with Server and Database node', async function (): Promise<void> {
|
it('Urn should be correct with Server and Database node', async function (): Promise<void> {
|
||||||
const leafNode: ExtHostObjectExplorerNodeStub =
|
const leafNode: ExtHostObjectExplorerNodeStub =
|
||||||
new ExtHostObjectExplorerNodeStub('Databases', undefined, 'Folder', undefined)
|
new ExtHostObjectExplorerNodeStub('Databases', 'MySchema', 'Folder', undefined)
|
||||||
.createChild(dbName, dbSchema, 'Database');
|
.createChild(dbName, dbSchema, 'Database');
|
||||||
should(await buildUrn(leafNode)).equal(
|
should(await buildUrn(leafNode)).equal(
|
||||||
`Server/Database[@Name='${escapedDbName}' and @Schema='${escapedDbSchema}']`);
|
`Server/Database[@Name='${escapedDbName}' and @Schema='${escapedDbSchema}']`);
|
||||||
@@ -92,9 +92,9 @@ describe('buildUrn Method Tests', () => {
|
|||||||
|
|
||||||
it('Urn should be correct with Multiple levels of Nodes', async function (): Promise<void> {
|
it('Urn should be correct with Multiple levels of Nodes', async function (): Promise<void> {
|
||||||
const rootNode: ExtHostObjectExplorerNodeStub =
|
const rootNode: ExtHostObjectExplorerNodeStub =
|
||||||
new ExtHostObjectExplorerNodeStub('Databases', undefined, 'Folder', undefined)
|
new ExtHostObjectExplorerNodeStub('Databases', 'MySchema', 'Folder', undefined)
|
||||||
.createChild(dbName, dbSchema, 'Database')
|
.createChild(dbName, dbSchema, 'Database')
|
||||||
.createChild('Tables', undefined, 'Folder')
|
.createChild('Tables', 'MySchema', 'Folder')
|
||||||
.createChild(tableName, tableSchema, 'Table');
|
.createChild(tableName, tableSchema, 'Table');
|
||||||
should(await buildUrn(rootNode)).equal(
|
should(await buildUrn(rootNode)).equal(
|
||||||
`Server/Database[@Name='${escapedDbName}' and @Schema='${escapedDbSchema}']/Table[@Name='${escapedTableName}' and @Schema='${escapedTableSchema}']`);
|
`Server/Database[@Name='${escapedDbName}' and @Schema='${escapedDbSchema}']/Table[@Name='${escapedTableName}' and @Schema='${escapedTableSchema}']`);
|
||||||
@@ -102,10 +102,10 @@ describe('buildUrn Method Tests', () => {
|
|||||||
|
|
||||||
it('Urn should be correct with Multiple levels of Nodes without schemas', async function (): Promise<void> {
|
it('Urn should be correct with Multiple levels of Nodes without schemas', async function (): Promise<void> {
|
||||||
const rootNode: ExtHostObjectExplorerNodeStub =
|
const rootNode: ExtHostObjectExplorerNodeStub =
|
||||||
new ExtHostObjectExplorerNodeStub('Databases', undefined, 'Folder', undefined)
|
new ExtHostObjectExplorerNodeStub('Databases', '', 'Folder', undefined)
|
||||||
.createChild(dbName, undefined, 'Database')
|
.createChild(dbName, '', 'Database')
|
||||||
.createChild('Tables', undefined, 'Folder')
|
.createChild('Tables', '', 'Folder')
|
||||||
.createChild(tableName, undefined, 'Table');
|
.createChild(tableName, '', 'Table');
|
||||||
should(await buildUrn(rootNode)).equal(
|
should(await buildUrn(rootNode)).equal(
|
||||||
`Server/Database[@Name='${escapedDbName}']/Table[@Name='${escapedTableName}']`);
|
`Server/Database[@Name='${escapedDbName}']/Table[@Name='${escapedTableName}']`);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ export const nodeTypeToUrnNameMapping: { [oeNodeType: string]: SmoMapping } = {
|
|||||||
* Builds the URN string for a given ObjectExplorerNode in the form understood by SsmsMin
|
* Builds the URN string for a given ObjectExplorerNode in the form understood by SsmsMin
|
||||||
* @param node The node to get the URN of
|
* @param node The node to get the URN of
|
||||||
*/
|
*/
|
||||||
export async function buildUrn(node: azdata.objectexplorer.ObjectExplorerNode): Promise<string> {
|
export async function buildUrn(node?: azdata.objectexplorer.ObjectExplorerNode): Promise<string> {
|
||||||
let urnNodes: string[] = [];
|
let urnNodes: string[] = [];
|
||||||
while (node) {
|
while (node) {
|
||||||
// Server is special since it's a connection node - always add it as the root
|
// Server is special since it's a connection node - always add it as the root
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"strict": false,
|
"strict": false,
|
||||||
"noUnusedParameters": false
|
"noUnusedParameters": false,
|
||||||
|
"strictNullChecks": false
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules"
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
"noUnusedParameters": false,
|
"noUnusedParameters": false,
|
||||||
"typeRoots": [
|
"typeRoots": [
|
||||||
"./node_modules/@types"
|
"./node_modules/@types"
|
||||||
]
|
],
|
||||||
|
"strictNullChecks": false
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*"
|
"src/**/*"
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
],
|
],
|
||||||
"strict": false,
|
"strict": false,
|
||||||
"noUnusedParameters": false,
|
"noUnusedParameters": false,
|
||||||
|
"strictNullChecks": false
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules"
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
"declaration": false,
|
"declaration": false,
|
||||||
"strict": false,
|
"strict": false,
|
||||||
"noUnusedParameters": false,
|
"noUnusedParameters": false,
|
||||||
|
"strictNullChecks": false
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules"
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./out",
|
"outDir": "./out",
|
||||||
"strict": false,
|
"strict": false,
|
||||||
"noUnusedParameters": false
|
"noUnusedParameters": false,
|
||||||
|
"strictNullChecks": false
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*"
|
"src/**/*"
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
"declaration": false,
|
"declaration": false,
|
||||||
"strict": false,
|
"strict": false,
|
||||||
"noUnusedParameters": false,
|
"noUnusedParameters": false,
|
||||||
|
"strictNullChecks": false
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"strict": false,
|
"strict": false,
|
||||||
"noUnusedParameters": false,
|
"noUnusedParameters": false,
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
|
"strictNullChecks": false
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*"
|
"src/**/*"
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./out",
|
"outDir": "./out",
|
||||||
"strict": false,
|
"strict": false,
|
||||||
"noUnusedParameters": false
|
"noUnusedParameters": false,
|
||||||
|
"strictNullChecks": false
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*"
|
"src/**/*"
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./out",
|
"outDir": "./out",
|
||||||
"strict": false,
|
"strict": false,
|
||||||
"noUnusedParameters": false
|
"noUnusedParameters": false,
|
||||||
|
"strictNullChecks": false
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*"
|
"src/**/*"
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
"noUnusedParameters": false,
|
"noUnusedParameters": false,
|
||||||
"typeRoots": [
|
"typeRoots": [
|
||||||
"./node_modules/@types"
|
"./node_modules/@types"
|
||||||
]
|
],
|
||||||
|
"strictNullChecks": false
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*"
|
"src/**/*"
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
"noUnusedParameters": false,
|
"noUnusedParameters": false,
|
||||||
"noImplicitReturns": false,
|
"noImplicitReturns": false,
|
||||||
"noUnusedLocals": false,
|
"noUnusedLocals": false,
|
||||||
|
"strictNullChecks": false
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules"
|
||||||
|
|||||||
@@ -26,12 +26,11 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
"exactOptionalPropertyTypes": false,
|
"exactOptionalPropertyTypes": false,
|
||||||
"useUnknownInCatchVariables": false,
|
"useUnknownInCatchVariables": false,
|
||||||
"alwaysStrict": true,
|
|
||||||
"noImplicitAny": true,
|
|
||||||
"noImplicitReturns": true,
|
"noImplicitReturns": true,
|
||||||
"noImplicitOverride": true,
|
"noImplicitOverride": true,
|
||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
"noUnusedParameters": true,
|
"noUnusedParameters": true,
|
||||||
"forceConsistentCasingInFileNames": true
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"strictNullChecks": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user