refactor: use interface instead of type

This commit is contained in:
Crawl 2018-04-30 11:36:49 +02:00
parent 389757d7e2
commit dbb504c1fe
No known key found for this signature in database
GPG key ID: E41A6DB922EC2CFE
2 changed files with 54 additions and 49 deletions

View file

@ -17,6 +17,12 @@ import {
import { statSync } from 'fs';
const lang = require('./data/languages.json');
interface FileDetail {
size: string | null;
totalLines: string | null;
currentLine: string | null;
}
const knownExtentions: { [x: string]: { image: string } } = lang.knownExtentions;
const knownLanguages: string[] = lang.knownLanguages;
@ -156,7 +162,7 @@ function initRPC(clientID: string, loud?: boolean): void {
// Announce failure
if (!config.get('silent')) {
if (error.message.includes('ENOENT')) window.showErrorMessage('No Discord Client detected!');
else window.showErrorMessage(`Couldn't connect to Discord via RPC: ${error.message}`);
else window.showErrorMessage(`Couldn't connect to Discord via RPC: ${error.toString()}`);
createButton();
}
});
@ -271,8 +277,8 @@ function generateDetails(debugging, editing, idling): string {
dirName = split[split.length - 1];
}
const checkState: boolean = window.activeTextEditor
? Boolean(workspace.getWorkspaceFolder(window.activeTextEditor.document.uri))
: false;
? Boolean(workspace.getWorkspaceFolder(window.activeTextEditor.document.uri))
: false;
const workspaceFolder: WorkspaceFolder = checkState ? workspace.getWorkspaceFolder(window.activeTextEditor.document.uri) : null;
@ -355,9 +361,3 @@ function getFileDetails(rawString): FileDetail {
}
return obj;
}
type FileDetail = {
size: string | null,
totalLines: string | null,
currentLine: string | null,
};

View file

@ -3,8 +3,8 @@
"@types/node@^9.0.0":
version "9.6.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.1.tgz#e2d374ef15b315b48e7efc308fa1a7cd51faa06c"
version "9.6.7"
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.7.tgz#5f3816d1db2155edcde1b2e3aa5d0e5c520cb564"
ajv@^5.1.0:
version "5.5.2"
@ -133,8 +133,8 @@ aws-sign2@~0.7.0:
resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8"
aws4@^1.2.1, aws4@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e"
version "1.7.0"
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.7.0.tgz#d4d0e9b9dbfca77bf08eeb0a8a471550fe39e289"
babel-code-frame@^6.22.0:
version "6.26.0"
@ -205,6 +205,10 @@ buffer-crc32@~0.2.3:
version "0.2.13"
resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242"
buffer-from@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.0.0.tgz#4cb8832d23612589b0406e9e2956c17f06fdf531"
builtin-modules@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
@ -228,8 +232,8 @@ chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3:
supports-color "^2.0.0"
chalk@^2.3.0:
version "2.3.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.2.tgz#250dc96b07491bfd601e648d66ddf5f60c7a5c65"
version "2.4.1"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e"
dependencies:
ansi-styles "^3.2.1"
escape-string-regexp "^1.0.5"
@ -256,8 +260,8 @@ clone@^1.0.0:
resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e"
clone@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f"
version "2.1.1"
resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.1.tgz#d217d1e961118e3ac9a4b8bba3285553bf647cdb"
cloneable-readable@^1.0.0:
version "1.1.2"
@ -359,14 +363,14 @@ diff@^3.2.0:
"discord-rpc@github:discordjs/rpc":
version "3.0.0-beta.10"
resolved "https://codeload.github.com/discordjs/rpc/tar.gz/1f978909a6b6ccfe7aeaf7e44cb1dfef2a7692f4"
resolved "https://codeload.github.com/discordjs/rpc/tar.gz/175aa54a7f12b4e2958605b874aafdb3adeb0c63"
dependencies:
discord.js "github:discordjs/discord.js"
snekfetch "^3.5.8"
"discord.js@github:discordjs/discord.js":
version "12.0.0-dev"
resolved "https://codeload.github.com/discordjs/discord.js/tar.gz/623d4c0076c49b4df827dbc4ef064e9b098bc229"
resolved "https://codeload.github.com/discordjs/discord.js/tar.gz/745669a7c9ade99d04803770ba3a222f74074f6d"
dependencies:
pako "^1.0.0"
prism-media "^0.2.0"
@ -1319,8 +1323,8 @@ preserve@^0.2.0:
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
prism-media@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/prism-media/-/prism-media-0.2.0.tgz#82c183da430c41c3025df3610a92a61b107b1918"
version "0.2.1"
resolved "https://registry.yarnpkg.com/prism-media/-/prism-media-0.2.1.tgz#7968f2c7194588887c4c48081968d8c28e0d2469"
process-nextick-args@^2.0.0, process-nextick-args@~2.0.0:
version "2.0.0"
@ -1338,9 +1342,9 @@ qs@~6.5.1:
version "6.5.1"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"
querystringify@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-1.0.0.tgz#6286242112c5b712fa654e526652bf6a13ff05cb"
querystringify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.0.0.tgz#fa3ed6e68eb15159457c89b37bc6472833195755"
queue@^3.1.0:
version "3.1.0"
@ -1371,15 +1375,15 @@ randomatic@^1.1.3:
string_decoder "~0.10.x"
readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.5, readable-stream@^2.1.5, readable-stream@^2.3.5:
version "2.3.5"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.5.tgz#b4f85003a938cbb6ecbce2a124fb1012bd1a838d"
version "2.3.6"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"
dependencies:
core-util-is "~1.0.0"
inherits "~2.0.3"
isarray "~1.0.0"
process-nextick-args "~2.0.0"
safe-buffer "~5.1.1"
string_decoder "~1.0.3"
string_decoder "~1.1.1"
util-deprecate "~1.0.1"
readable-stream@~1.1.9:
@ -1469,13 +1473,13 @@ request@~2.79.0:
tunnel-agent "~0.4.1"
uuid "^3.0.0"
requires-port@~1.0.0:
requires-port@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
resolve@^1.3.2:
version "1.6.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.6.0.tgz#0fbd21278b27b4004481c395349e7aba60a9ff5c"
version "1.7.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.7.1.tgz#aadd656374fd298aee895bc026b8297418677fd3"
dependencies:
path-parse "^1.0.5"
@ -1486,8 +1490,8 @@ rimraf@2:
glob "^7.0.5"
safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
version "5.1.2"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
semver@^5.3.0, semver@^5.4.1:
version "5.5.0"
@ -1510,9 +1514,10 @@ sntp@2.x.x:
hoek "4.x.x"
source-map-support@^0.5.0:
version "0.5.4"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.4.tgz#54456efa89caa9270af7cd624cc2f123e51fbae8"
version "0.5.5"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.5.tgz#0d4af9e00493e855402e8ec36ebed2d266fceb90"
dependencies:
buffer-from "^1.0.0"
source-map "^0.6.0"
source-map@^0.6.0:
@ -1575,9 +1580,9 @@ string_decoder@~0.10.x:
version "0.10.31"
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94"
string_decoder@~1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab"
string_decoder@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8"
dependencies:
safe-buffer "~5.1.0"
@ -1615,8 +1620,8 @@ supports-color@^2.0.0:
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
supports-color@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.3.0.tgz#5b24ac15db80fa927cf5227a4a33fd3c4c7676c0"
version "5.4.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.4.0.tgz#1c6b337402c2137605efe19f10fec390f6faab54"
dependencies:
has-flag "^3.0.0"
@ -1691,8 +1696,8 @@ tslint@^5.0.0:
tsutils "^2.12.1"
tsutils@^2.12.1:
version "2.25.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.25.0.tgz#14d616ef59224a3c9fb7eb483e1c182b6665ae5e"
version "2.26.2"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.26.2.tgz#a9f9f63434a456a5e0c95a45d9a59181cb32d3bf"
dependencies:
tslib "^1.8.1"
@ -1715,8 +1720,8 @@ tweetnacl@^1.0.0:
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.0.tgz#713d8b818da42068740bf68386d0479e66fc8a7b"
typescript@^2.0.0:
version "2.8.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.8.1.tgz#6160e4f8f195d5ba81d4876f9c0cc1fbc0820624"
version "2.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.8.3.tgz#5d817f9b6f31bb871835f4edf0089f21abe6c170"
unique-stream@^2.0.2:
version "2.2.1"
@ -1726,11 +1731,11 @@ unique-stream@^2.0.2:
through2-filter "^2.0.0"
url-parse@^1.1.9:
version "1.2.0"
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.2.0.tgz#3a19e8aaa6d023ddd27dcc44cb4fc8f7fec23986"
version "1.4.0"
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.4.0.tgz#6bfdaad60098c7fe06f623e42b22de62de0d3d75"
dependencies:
querystringify "~1.0.0"
requires-port "~1.0.0"
querystringify "^2.0.0"
requires-port "^1.0.0"
util-deprecate@~1.0.1:
version "1.0.2"
@ -1828,8 +1833,8 @@ vinyl@~2.0.1:
replace-ext "^1.0.0"
vscode@^1.0.0:
version "1.1.14"
resolved "https://registry.yarnpkg.com/vscode/-/vscode-1.1.14.tgz#f327f5fd45c085d12def616962af205b2bc75db5"
version "1.1.16"
resolved "https://registry.yarnpkg.com/vscode/-/vscode-1.1.16.tgz#2eb2c76bff39b364597968a3a71c6ad2b902298c"
dependencies:
glob "^7.1.2"
gulp-chmod "^2.0.0"