Skip to content

Commit b906516

Browse files
author
Drizzy
committed
Improvement in variable types
1 parent a833f91 commit b906516

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/CodeManager.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import * as vscode from 'vscode';
22
import { StatusBarItems } from './interface';
33
import { join, resolve } from 'path';
44
import { platform } from 'os';
5-
import { existsSync, mkdirSync, readdirSync, writeFile, statSync } from 'fs';
6-
import { gitignore, maincpp, makefile, readme } from './templates'
5+
import { existsSync, mkdirSync, readdirSync, writeFile, statSync, Stats } from 'fs';
6+
import { gitignore, maincpp, makefile, readme } from './templates';
77

88
export class CodeManage {
99

1010
private _terminal: vscode.Terminal;
1111
private _folderPath: string;
1212
private _items: StatusBarItems;
13-
private _watcher: vscode.FileSystemWatcher | null
13+
private _watcher: vscode.FileSystemWatcher | null;
1414

1515
constructor(){
1616

@@ -22,7 +22,7 @@ export class CodeManage {
2222
this._items = {
2323
create: vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right),
2424
start: vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right),
25-
}
25+
};
2626
this._watcher = null;
2727
this.setupFileSystemWatcher();
2828
this.updateStatusBar();
@@ -35,13 +35,13 @@ export class CodeManage {
3535

3636
try {
3737

38-
const binStats = statSync(binPath);
38+
const binStats: Stats = statSync(binPath);
3939

4040
if (!binStats.isDirectory()) {
4141
this.build();
4242
} else {
43-
const files = readdirSync(binPath);
44-
if (files.length == 0) {
43+
const files: string[] = readdirSync(binPath);
44+
if (files.length === 0) {
4545
this.build();
4646
} else {
4747
this.build();
@@ -76,7 +76,7 @@ export class CodeManage {
7676
'tests'
7777
];
7878

79-
folders.forEach((folder) => this.createFolder(this._folderPath, folder));
79+
folders.forEach((folder: string) => this.createFolder(this._folderPath, folder));
8080

8181
this.createFile(join(this._folderPath, 'src', 'main.cpp'), maincpp);
8282
this.createFile(join(this._folderPath, '.gitignore'), gitignore);
@@ -153,7 +153,7 @@ export class CodeManage {
153153
this._terminal.sendText(`${command}`);
154154

155155
} catch (e: any) {
156-
vscode.window.showErrorMessage(e);
156+
vscode.window.showErrorMessage(e.message || e.toString());
157157
}
158158

159159
}
@@ -175,12 +175,11 @@ export class CodeManage {
175175
private createFile(filePath: string, templatePath: string) {
176176

177177
if(!existsSync(filePath)){
178-
writeFile(filePath, templatePath, 'utf8', (err) => {
178+
writeFile(filePath, templatePath, 'utf8', (err: NodeJS.ErrnoException | null) => {
179179
if(err){
180-
console.error(err)
181180
vscode.window.showErrorMessage('Failed to create file');
182181
}
183-
})
182+
});
184183
}
185184

186185
}

src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ export function activate(context: vscode.ExtensionContext) {
99

1010
const manager = new CodeManage();
1111

12-
const create = vscode.commands.registerCommand('code-make-create.run', () => {
12+
const create: vscode.Disposable = vscode.commands.registerCommand('code-make-create.run', () => {
1313
manager.create();
1414
});
1515

16-
const start = vscode.commands.registerCommand('code-make-start.run', () => {
16+
const start: vscode.Disposable = vscode.commands.registerCommand('code-make-start.run', () => {
1717
manager.start();
1818
});
1919

0 commit comments

Comments
 (0)