Skip to content

Commit b09bae0

Browse files
chore(deps-dev): bump typescript from 5.9.3 to 6.0.3 (#961)
* chore(deps-dev): bump typescript from 5.9.3 to 6.0.3 Bumps [typescript](https://github.com/microsoft/TypeScript) from 5.9.3 to 6.0.3. - [Release notes](https://github.com/microsoft/TypeScript/releases) - [Commits](microsoft/TypeScript@v5.9.3...v6.0.3) --- updated-dependencies: - dependency-name: typescript dependency-version: 6.0.3 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * chore(tests): update test script to specify TS_NODE_PROJECT and add tsconfig for tests --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kjetil Muggerud <44665004+kmugEq@users.noreply.github.com>
1 parent 88ca899 commit b09bae0

14 files changed

Lines changed: 132 additions & 101 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"prettier": "^3.8.4",
1919
"source-map-support": "^0.5.21",
2020
"ts-node": "^10.9.2",
21-
"typescript": "5.9.3",
21+
"typescript": "6.0.3",
2222
"typescript-eslint": "^8.62.0"
2323
},
2424
"engines": {

packages/extension/client/src/commands.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export function registerCommandAddTemplate(
152152
vscode.commands.registerCommand(
153153
"septic.scgtree.addTemplate",
154154
async (node: ApplicationTreeItem) => {
155-
if (!node) {
155+
if (!node || !node.config) {
156156
return;
157157
}
158158
const template = await vscode.window.showInputBox({
@@ -199,7 +199,7 @@ export function registerCommandRemoveTemplate(
199199
vscode.commands.registerCommand(
200200
"septic.scgtree.removeTemplate",
201201
async (node: ApplicationTreeItem) => {
202-
if (!node) {
202+
if (!node || !node.config) {
203203
return;
204204
}
205205
const confirmation = await vscode.window.showQuickPick(
@@ -225,7 +225,7 @@ export function registerCommandRenameTemplate(
225225
vscode.commands.registerCommand(
226226
"septic.scgtree.renameTemplate",
227227
async (node: ApplicationTreeItem) => {
228-
if (!node) {
228+
if (!node || !node.config) {
229229
return;
230230
}
231231
const newName = await vscode.window.showInputBox({
@@ -253,7 +253,7 @@ export function registerCommandAddSource(
253253
vscode.commands.registerCommand(
254254
"septic.scgtree.addSource",
255255
async (node: ApplicationTreeItem) => {
256-
if (!node) {
256+
if (!node || !node.config) {
257257
return;
258258
}
259259
const newName = await vscode.window.showInputBox({
@@ -371,11 +371,11 @@ export function registerCommandMakeConfig() {
371371
});
372372
const terminal = vscode.window.createTerminal({
373373
name: `Septic: Make scg config`,
374-
cwd: path.dirname(e.config.path),
374+
cwd: path.dirname(e.config?.path ?? ""),
375375
});
376376
terminal.show();
377377
terminal.sendText(`scg make ${e.label} ${args}`);
378-
if (e.config.outputfile) {
378+
if (e.config?.outputfile) {
379379
vscode.window.showTextDocument(
380380
vscode.Uri.file(e.config.outputfile),
381381
);

packages/extension/client/src/mdf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function parseMdf(input: string): MdfData {
2525
if (key === 'nsecs' || key === 'amodl' || key === 'bmodl') {
2626
value = Number(value);
2727
}
28-
result[key] = value;
28+
(result as Record<string, string | number>)[key] = value;
2929
return true;
3030
}
3131
return false;

packages/extension/client/src/scg.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ export class ScgConfig {
111111
}
112112

113113
public async updateConfig() {
114-
this.config = await readScgConfig(this.path);
114+
const config = await readScgConfig(this.path);
115+
if (config) {
116+
this.config = config;
117+
}
115118
}
116119

117120
get name(): string {
@@ -183,7 +186,7 @@ export class ScgSource {
183186
this.delimiter = delimiter;
184187
}
185188

186-
private async getData(): Promise<string[][]> {
189+
private async getData(): Promise<string[][] | undefined> {
187190
if (!this.data) {
188191
try {
189192
this.data = await this.load();

packages/extension/client/src/test/commands.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ suite("Test OPC-taglist command", async () => {
4141

4242
await commandPromise;
4343
await sleep(100);
44-
const wsPath = vscode.workspace.workspaceFolders[0].uri.fsPath;
44+
const wsPath = vscode.workspace.workspaceFolders?.[0].uri.fsPath ?? "";
4545
const expectedFileName = "opc_tags_scg.csv";
4646
const filePath = vscode.Uri.file(`${wsPath}/${expectedFileName}`);
4747

@@ -72,7 +72,7 @@ suite("Test OPC-taglist command", async () => {
7272

7373
await commandPromise;
7474
await sleep(100);
75-
const wsPath = vscode.workspace.workspaceFolders[0].uri.fsPath;
75+
const wsPath = vscode.workspace.workspaceFolders?.[0].uri.fsPath ?? "";
7676
const expectedFileName = "opc_tags_test.csv";
7777
const filePath = vscode.Uri.file(`${wsPath}/${expectedFileName}`);
7878

packages/extension/client/src/test/helper.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export async function activate() {
2020
}
2121
try {
2222
const ext = vscode.extensions.getExtension("EinarSIdso.septic-config");
23+
if (!ext) {
24+
return;
25+
}
2326
await ext.activate();
2427
await sleep(2000);
2528
activated = true;

packages/extension/client/src/tools.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ export class GetVariables implements vscode.LanguageModelTool<GetVariablesParams
7777
options.input.uri ??
7878
vscode.window.activeTextEditor?.document.uri.toString();
7979
const variables = await this.client.sendRequest(protocol.variables, {
80-
uri: uri,
80+
uri: uri ?? "",
8181
});
8282
const variablesString =
8383
variables
84-
?.map((variable) => {
84+
?.map((variable: { type: string; name: string; description: string }) => {
8585
return `${variable.type} ${variable.name}: ${variable.description}`;
8686
})
8787
.join("\n") ?? "";

packages/extension/client/src/treeProviders.ts

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export class ApplicationTreeProvider implements vscode.TreeDataProvider<Applicat
4141
return Promise.resolve([layout, sources]);
4242
} else if (element.type === ApplicationTreeItemType.Layout) {
4343
const items: ApplicationTreeItem[] = [];
44+
if (!element.config) {
45+
return Promise.resolve([]);
46+
}
4447
for (const layout of element.config.layout) {
4548
items.push(new ApplicationTreeItem(layout.name, ApplicationTreeItemType.Template, vscode.TreeItemCollapsibleState.None, element.config, {
4649
command: 'vscode.open',
@@ -51,6 +54,9 @@ export class ApplicationTreeProvider implements vscode.TreeDataProvider<Applicat
5154
return Promise.resolve(items);
5255
} else if (element.type === ApplicationTreeItemType.Sources) {
5356
const items: ApplicationTreeItem[] = [];
57+
if (!element.config) {
58+
return Promise.resolve([]);
59+
}
5460
const sources = await element.config.getSources();
5561
for (const source of sources) {
5662
items.push(new ApplicationTreeItem(source.id, ApplicationTreeItemType.Source, vscode.TreeItemCollapsibleState.Collapsed, element.config, {
@@ -61,6 +67,9 @@ export class ApplicationTreeProvider implements vscode.TreeDataProvider<Applicat
6167
}
6268
return Promise.resolve(items);
6369
} else if (element.type === ApplicationTreeItemType.Source) {
70+
if (!element.config) {
71+
return Promise.resolve([]);
72+
}
6473
const source = await element.config.getSourceById(element.label);
6574
if (!source) {
6675
return Promise.resolve([]);
@@ -81,7 +90,7 @@ export class ApplicationTreeProvider implements vscode.TreeDataProvider<Applicat
8190
const applications = await this.appManager.getApplications();
8291
const currentApplication = await this.appManager.getCurrentApplication();
8392
const applicationTreeItems = [];
84-
for (const app of applications) {
93+
for (const app of applications ?? []) {
8594
const itemState = app === currentApplication ? vscode.TreeItemCollapsibleState.Expanded : vscode.TreeItemCollapsibleState.Collapsed;
8695
applicationTreeItems.push(new ApplicationTreeItem(app.name, ApplicationTreeItemType.Application, itemState, undefined));
8796
}
@@ -119,7 +128,7 @@ export class ApplicationTreeItem extends vscode.TreeItem {
119128
public readonly label: string,
120129
public readonly type: ApplicationTreeItemType,
121130
public readonly collapsibleState: vscode.TreeItemCollapsibleState,
122-
public readonly config: ScgConfig,
131+
public readonly config: ScgConfig | undefined,
123132
public readonly command?: vscode.Command,
124133
public readonly source?: string
125134
) {
@@ -172,26 +181,30 @@ export class JinjaVariablesTreeProvider implements vscode.TreeDataProvider<Jinja
172181
if (!element) {
173182
return Promise.resolve(this.getJinjaVariables());
174183
}
184+
return [];
175185
}
176186

177187
private async getJinjaVariables(): Promise<JinjaVariableNode[]> {
178188
const scg = await this.appManager.getCurrentScgContext();
179189
if (!scg) {
180-
return undefined;
190+
return [];
181191
}
182192
const activeEditor = vscode.window.activeTextEditor;
183193
if (!activeEditor) {
184-
return undefined;
194+
return [];
185195
}
186196
const filePath = activeEditor.document.uri.fsPath;
187197
const template = scg.layout.find((t) => t.name === path.basename(filePath));
188198
if (!template || template.source === undefined) {
189-
return undefined;
199+
return [];
200+
}
201+
const source = await scg.getSourceById(template.source);
202+
if (!source) {
203+
return [];
190204
}
191-
const source = await scg.getSourceById(template.source)
192205
const columns = await source.getHeaders();
193206
if (!columns) {
194-
return undefined;
207+
return [];
195208
}
196209
return columns.map(column => new JinjaVariableNode(column, vscode.TreeItemCollapsibleState.None, source));
197210
}
@@ -254,7 +267,7 @@ export class SepticFunctionTreeProvider implements vscode.TreeDataProvider<Septi
254267
} else {
255268
label += `${line.name} = ${line.alg}`;
256269
}
257-
const uri = vscode.Uri.parse(line.uri).with({ fragment: 'L' + (line.pos.line + 1) });
270+
const uri = vscode.Uri.parse(line.uri).with({ fragment: 'L' + ((line.pos?.line ?? 0) + 1) });
258271
const command: vscode.Command = {
259272
command: 'vscode.open',
260273
title: 'Go to function',
@@ -265,7 +278,7 @@ export class SepticFunctionTreeProvider implements vscode.TreeDataProvider<Septi
265278
return Promise.resolve(lines)
266279
} else if (element.type === SepticFunctionTreeItemType.Inputs) {
267280
const inputs = element.func.inputs.map((input) => {
268-
const uri = vscode.Uri.parse(input.uri).with({ fragment: 'L' + (input.pos.line + 1) });
281+
const uri = vscode.Uri.parse(input.uri).with({ fragment: 'L' + ((input.pos?.line ?? 0) + 1) });
269282
const command: vscode.Command = {
270283
command: 'vscode.open',
271284
title: 'Go to function',
@@ -275,17 +288,17 @@ export class SepticFunctionTreeProvider implements vscode.TreeDataProvider<Septi
275288
});
276289
return Promise.resolve(inputs);
277290
}
278-
291+
return [];
279292
}
280293

281294
private async getSepticFunctions(): Promise<SepticFunctionTreeItem[]> {
282295
const activeEditor = vscode.window.activeTextEditor;
283296
if (!activeEditor) {
284-
return undefined;
297+
return [];
285298
}
286299
const functions: SepticFunctionExport[] = await this.client.sendRequest('septic/getFunctions', { uri: activeEditor.document.uri.toString() });
287300
if (!functions || functions.length === 0) {
288-
return this.functionsCache ? this.functionsCache.map(func => new SepticFunctionTreeItem(func.name, vscode.TreeItemCollapsibleState.Collapsed, func, SepticFunctionTreeItemType.Definition)) : undefined;
301+
return this.functionsCache ? this.functionsCache.map(func => new SepticFunctionTreeItem(func.name, vscode.TreeItemCollapsibleState.Collapsed, func, SepticFunctionTreeItemType.Definition)) : [];
289302
}
290303
this.functionsCache = functions;
291304
return functions.map(func => new SepticFunctionTreeItem(func.name, vscode.TreeItemCollapsibleState.Collapsed, func, SepticFunctionTreeItemType.Definition));

packages/extension/client/src/webviews.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function createMdfWebviewPanel(content: string, title: string): vscode.We
1010
{ enableScripts: true }
1111
);
1212
panel.webview.html = getMdfWebviewContent();
13-
const plotData = { amodel: parsedData.a ? { x: parsedData.a.map((val, idx) => (idx * parsedData.nsecs)) || [], y: parsedData.a || [] } : undefined, bmodel: parsedData.b ? { x: parsedData.b.map((val, idx) => (idx * parsedData.nsecs)) || [], y: parsedData.b || [] } : undefined, title: title };
13+
const plotData = { amodel: parsedData.a ? { x: parsedData.a.map((val, idx) => (idx * (parsedData.nsecs ?? 0))) || [], y: parsedData.a || [] } : undefined, bmodel: parsedData.b ? { x: parsedData.b.map((val, idx) => (idx * (parsedData.nsecs ?? 0))) || [], y: parsedData.b || [] } : undefined, title: title };
1414
panel.webview.postMessage({ type: 'plot', data: plotData });
1515
return panel;
1616
}

packages/extension/client/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"module": "nodenext",
44
"target": "es2024",
55
"lib": ["es2024"],
6+
"types": ["node", "mocha"],
67
"outDir": "out",
78
"rootDir": "src",
89
"sourceMap": true,

0 commit comments

Comments
 (0)