Skip to content

Commit 3cfb535

Browse files
committed
fix: handle null cases and enable typescript strict mode
1 parent b86da49 commit 3cfb535

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module '@playlyfe/gql-language-server' {
2+
export function findConfigFile(path: string): string;
3+
}

src/ClientStatusBarItem.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ export default class ClientStatusBarItem {
6969
this._disposables.forEach(item => {
7070
item.dispose();
7171
});
72-
this._item = null;
73-
this._client = null;
7472
}
7573

7674
private _registerStatusChangeListeners() {
@@ -101,11 +99,15 @@ export default class ClientStatusBarItem {
10199
return disposable;
102100
}
103101

104-
private _updateVisibility = (textEditor: TextEditor) => {
102+
private _updateVisibility = (textEditor: TextEditor | undefined) => {
105103
let hide = true;
106104

107105
if (textEditor) {
108-
if (this._client.initializeResult) {
106+
const workspaceFolder = workspace.getWorkspaceFolder(
107+
textEditor.document.uri,
108+
);
109+
110+
if (this._client.initializeResult && workspaceFolder) {
109111
// if client is initialized then show only for file extensions
110112
// defined in .gqlconfig
111113
// @TODO: if possible, match against patterns defined in .gqlconfig
@@ -115,7 +117,7 @@ export default class ClientStatusBarItem {
115117
{
116118
scheme: 'file',
117119
pattern: new RelativePattern(
118-
workspace.getWorkspaceFolder(textEditor.document.uri),
120+
workspaceFolder,
119121
`**/*.{${extensions.join(',')}}`,
120122
),
121123
},

src/extension.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ export function activate(context: ExtensionContext) {
3939
export function deactivate(): Thenable<void> {
4040
const promises: Array<Thenable<void>> = [];
4141
clients.forEach(client => {
42-
promises.push(client.dispose());
42+
if (client) {
43+
promises.push(client.dispose());
44+
}
4345
});
4446
return Promise.all(promises).then(() => undefined);
4547
}
4648

4749
function createClientForWorkspaces() {
4850
const workspaceFolders = Workspace.workspaceFolders || [];
49-
const workspaceFoldersIndex = {};
51+
const workspaceFoldersIndex: { [key: string]: boolean } = {};
5052

5153
workspaceFolders.forEach(folder => {
5254
const key = folder.uri.toString();

src/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"moduleResolution": "node",
66
"lib": [ "es6" ],
77
"outDir": "../out",
8-
"sourceMap": true
8+
"sourceMap": true,
9+
"noImplicitAny": true,
10+
"strictNullChecks": true
911
}
1012
}

0 commit comments

Comments
 (0)