fix: Build errors

Signed-off-by: Avior <f.bouillon@aptatio.com>
This commit is contained in:
2023-01-20 12:46:33 +01:00
parent 9eb417f340
commit e4b8ab4db8
8 changed files with 5615 additions and 6456 deletions

View File

@@ -13,8 +13,8 @@ if (typeof fetch === 'undefined') {
}
export class CodeStatsAPI {
private API_KEY = null;
private USER_NAME = null;
private API_KEY?: string;
private USER_NAME?: string;
private UPDATE_URL = "https://codestats.net/api";
private headers: Record<string, string> = {
"Content-Type": "application/json"
@@ -47,7 +47,6 @@ export class CodeStatsAPI {
return null;
}
// tslint:disable-next-line:typedef
const data = new ApiJSON(new Date());
for (let lang of pulse.xps.keys()) {
@@ -86,7 +85,7 @@ export class CodeStatsAPI {
class ApiJSON {
constructor(date: Date) {
this.coded_at = getISOTimestamp(new Date());
this.coded_at = getISOTimestamp(date);
this.xps = new Array<ApiXP>();
}

View File

@@ -1,5 +1,5 @@
import { CancellationToken, Event, ExtensionContext, TextDocumentContentProvider, Uri, workspace } from "vscode"
import { CancellationToken, Event, ExtensionContext, TextDocumentContentProvider, Uri } from "vscode"
import { CodeStatsAPI } from "./code-stats-api"
import profileHtmlEex from './profile.html.eex'
@@ -16,9 +16,9 @@ export class ProfileProvider implements TextDocumentContentProvider {
this.api = api;
}
provideTextDocumentContent(uri: Uri, token: CancellationToken): string | Thenable<string> {
provideTextDocumentContent(_uri: Uri, token: CancellationToken): string | Thenable<string> {
if (token.isCancellationRequested) return;
if (token.isCancellationRequested) return '';
const LEVEL_FACTOR = 0.025;

View File

@@ -6,7 +6,7 @@ export class Pulse {
}
public getXP(language: string): number {
let xp: number = this.xps.get(language);
let xp = this.xps.get(language);
if (xp === null || xp === undefined) {
return 0;

View File

@@ -11,7 +11,7 @@ export class XpCounter {
private combinedDisposable: Disposable;
private statusBarItem: StatusBarItem;
private pulse: Pulse;
private api: CodeStatsAPI;
private api!: CodeStatsAPI;
private updateTimeout: any;
// wait 10s after each change in the document before sending an update
@@ -33,10 +33,8 @@ export class XpCounter {
let subscriptions: Disposable[] = [];
if (!this.statusBarItem) {
this.statusBarItem = window.createStatusBarItem(StatusBarAlignment.Left);
this.statusBarItem.command = "code-stats.profile";
}
this.statusBarItem = window.createStatusBarItem(StatusBarAlignment.Left);
this.statusBarItem.command = "code-stats.profile";
subscriptions.push(workspace.registerTextDocumentContentProvider('code-stats', new ProfileProvider(context, this.api)));
@@ -166,9 +164,9 @@ export class XpCounter {
return;
}
const apiKey: string = config.get("apikey");
const apiURL: string = config.get("apiurl");
const userName: string = config.get("username");
const apiKey = config.get("apikey") as string;
const apiURL = config.get("apiurl") as string;
const userName = config.get("username") as string;
console.log(
`code-stats-vscode setting up:
@@ -178,9 +176,7 @@ export class XpCounter {
`
);
if(this.api != null )
this.api.updateSettings(apiKey, apiURL, userName);
else
this.api = new CodeStatsAPI(apiKey,apiURL,userName);
if(this.api != null ) this.api.updateSettings(apiKey, apiURL, userName);
else this.api = new CodeStatsAPI(apiKey,apiURL,userName);
}
}