Add TSLint to github actions, fix existing type errors

This commit is contained in:
Bjorn Stromberg 2020-07-22 11:15:16 +09:00
parent 79e7fb31b9
commit cb1ff53338
13 changed files with 38 additions and 72 deletions

View File

@ -44,3 +44,7 @@ jobs:
uses: ibiqlik/action-yamllint@v1.0.0 uses: ibiqlik/action-yamllint@v1.0.0
with: with:
file_or_dir: translations/*.yaml file_or_dir: translations/*.yaml
- name: TSLint
run: |
yarn tslint

View File

@ -201,33 +201,6 @@
flex-grow: 1; flex-grow: 1;
@include S(margin-bottom, 10px); @include S(margin-bottom, 10px);
} }
.contest {
flex-grow: 1;
background: rgb(32, 187, 166);
@include S(padding, 15px);
h3 {
@include Heading;
color: #fff;
font-weight: bold;
text-transform: uppercase;
@include S(margin-bottom, 5px);
}
p {
color: #fff;
@include Text;
strong {
font-weight: bold;
}
@include S(margin-bottom, 5px);
}
button {
background: #fff;
color: #333538;
}
}
} }
.mainContainer { .mainContainer {

View File

@ -385,7 +385,7 @@ export class Application {
} }
const scale = this.getEffectiveUiScale(); const scale = this.getEffectiveUiScale();
waitNextFrame().then(() => document.documentElement.style.setProperty("--ui-scale", scale)); waitNextFrame().then(() => document.documentElement.style.setProperty("--ui-scale", `${scale}`));
window.focus(); window.focus();
} }
} }

View File

@ -15,7 +15,9 @@ export class HUDEntityDebugger extends BaseHUDPart {
` `
); );
/** @type {HTMLElement} */
this.mousePosElem = this.element.querySelector(".mousePos"); this.mousePosElem = this.element.querySelector(".mousePos");
/** @type {HTMLElement} */
this.chunkPosElem = this.element.querySelector(".chunkPos"); this.chunkPosElem = this.element.querySelector(".chunkPos");
this.entityInfoElem = this.element.querySelector(".entityInfo"); this.entityInfoElem = this.element.querySelector(".entityInfo");
} }

View File

@ -23,7 +23,7 @@ export class HUDSettingsMenu extends BaseHUDPart {
<strong>${T.ingame.settingsMenu.beltsPlaced}</strong><span class="beltsPlaced"></span> <strong>${T.ingame.settingsMenu.beltsPlaced}</strong><span class="beltsPlaced"></span>
<strong>${T.ingame.settingsMenu.buildingsPlaced}</strong><span class="buildingsPlaced"></span> <strong>${T.ingame.settingsMenu.buildingsPlaced}</strong><span class="buildingsPlaced"></span>
<strong>${T.ingame.settingsMenu.playtime}</strong><span class="playtime"></span> <strong>${T.ingame.settingsMenu.playtime}</strong><span class="playtime"></span>
` `
); );
@ -106,16 +106,22 @@ export class HUDSettingsMenu extends BaseHUDPart {
this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReciever); this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReciever);
const totalMinutesPlayed = Math.ceil(this.root.time.now() / 60); const totalMinutesPlayed = Math.ceil(this.root.time.now() / 60);
this.statsElement.querySelector(".playtime").innerText = T.global.time.xMinutes.replace(
"<x>",
"" + totalMinutesPlayed
);
this.statsElement.querySelector(".buildingsPlaced").innerText = formatBigNumberFull( /** @type {HTMLElement} */
const playtimeElement = this.statsElement.querySelector(".playtime");
/** @type {HTMLElement} */
const buildingsPlacedElement = this.statsElement.querySelector(".buildingsPlaced");
/** @type {HTMLElement} */
const beltsPlacedElement = this.statsElement.querySelector(".beltsPlaced");
playtimeElement.innerText = T.global.time.xMinutes.replace("<x>", `${totalMinutesPlayed}`);
buildingsPlacedElement.innerText = formatBigNumberFull(
this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent).length - this.root.entityMgr.getAllWithComponent(StaticMapEntityComponent).length -
this.root.entityMgr.getAllWithComponent(BeltComponent).length this.root.entityMgr.getAllWithComponent(BeltComponent).length
); );
this.statsElement.querySelector(".beltsPlaced").innerText = formatBigNumberFull(
beltsPlacedElement.innerText = formatBigNumberFull(
this.root.entityMgr.getAllWithComponent(BeltComponent).length this.root.entityMgr.getAllWithComponent(BeltComponent).length
); );
} }

12
src/js/globals.d.ts vendored
View File

@ -36,11 +36,6 @@ declare interface CanvasRenderingContext2D {
webkitImageSmoothingEnabled: boolean; webkitImageSmoothingEnabled: boolean;
} }
declare interface HTMLCanvasElement {
opaque: boolean;
webkitOpaque: boolean;
}
// Just for compatibility with the shared code // Just for compatibility with the shared code
declare interface Logger { declare interface Logger {
log(...args); log(...args);
@ -127,13 +122,6 @@ declare interface NodeRequire {
context(src: string, flag: boolean, regexp: RegExp): WebpackContext; context(src: string, flag: boolean, regexp: RegExp): WebpackContext;
} }
// HTML Element
declare interface Element {
style: any;
innerText: string;
innerHTML: string;
}
declare interface Object { declare interface Object {
entries(obj: object): Array<[string, any]>; entries(obj: object): Array<[string, any]>;
} }

View File

@ -102,7 +102,10 @@ export class AdinplayAdProvider extends AdProviderInterface {
// Add the player // Add the player
const videoElement = this.adContainerMainElement.querySelector(".videoInner"); const videoElement = this.adContainerMainElement.querySelector(".videoInner");
this.adContainerMainElement.querySelector(".adInner").style.maxWidth = w + "px"; /** @type {HTMLElement} */
const adInnerElement = this.adContainerMainElement.querySelector(".adInner");
adInnerElement.style.maxWidth = w + "px";
const self = this; const self = this;
window.aiptag.cmd.player.push(function () { window.aiptag.cmd.player.push(function () {

View File

@ -40,7 +40,7 @@ export class BaseSetting {
/** /**
* @param {Application} app * @param {Application} app
* @param {Element} element * @param {HTMLElement} element
* @param {any} dialogs * @param {any} dialogs
*/ */
bind(app, element, dialogs) { bind(app, element, dialogs) {
@ -188,7 +188,7 @@ export class BoolSetting extends BaseSetting {
return ` return `
<div class="setting cardbox ${this.enabled ? "enabled" : "disabled"}"> <div class="setting cardbox ${this.enabled ? "enabled" : "disabled"}">
${this.enabled ? "" : `<span class="standaloneOnlyHint">${T.demo.settingNotAvailable}</span>`} ${this.enabled ? "" : `<span class="standaloneOnlyHint">${T.demo.settingNotAvailable}</span>`}
<div class="row"> <div class="row">
<label>${T.settings.labels[this.id].title}</label> <label>${T.settings.labels[this.id].title}</label>
<div class="value checkbox checked" data-setting="${this.id}"> <div class="value checkbox checked" data-setting="${this.id}">

View File

@ -46,7 +46,7 @@ export class MainMenuState extends GameState {
: "" : ""
} }
</div> </div>
<video autoplay muted loop class="fullscreenBackgroundVideo"> <video autoplay muted loop class="fullscreenBackgroundVideo">
<source src="${cachebust("res/bg_render.webm")}" type="video/webm"> <source src="${cachebust("res/bg_render.webm")}" type="video/webm">
</video> </video>
@ -92,10 +92,10 @@ export class MainMenuState extends GameState {
<a class="redditLink">${T.mainMenu.subreddit}</a> <a class="redditLink">${T.mainMenu.subreddit}</a>
<a class="changelog">${T.changelog.title}</a> <a class="changelog">${T.changelog.title}</a>
<a class="helpTranslate">${T.mainMenu.helpTranslate}</a> <a class="helpTranslate">${T.mainMenu.helpTranslate}</a>
</div> </div>
<div class="author">${T.mainMenu.madeBy.replace( <div class="author">${T.mainMenu.madeBy.replace(
"<author-link>", "<author-link>",
'<a class="producerLink" target="_blank">Tobias Springer</a>' '<a class="producerLink" target="_blank">Tobias Springer</a>'
@ -218,11 +218,6 @@ export class MainMenuState extends GameState {
this.trackClicks(qs(".languageChoose"), this.onLanguageChooseClicked); this.trackClicks(qs(".languageChoose"), this.onLanguageChooseClicked);
this.trackClicks(qs(".helpTranslate"), this.onTranslationHelpLinkClicked); this.trackClicks(qs(".helpTranslate"), this.onTranslationHelpLinkClicked);
const contestButton = qs(".participateContest");
if (contestButton) {
this.trackClicks(contestButton, this.onContestClicked);
}
if (G_IS_STANDALONE) { if (G_IS_STANDALONE) {
this.trackClicks(qs(".exitAppButton"), this.onExitAppButtonClicked); this.trackClicks(qs(".exitAppButton"), this.onExitAppButtonClicked);
} }
@ -312,15 +307,6 @@ export class MainMenuState extends GameState {
this.app.platformWrapper.openExternalLink(THIRDPARTY_URLS.reddit); this.app.platformWrapper.openExternalLink(THIRDPARTY_URLS.reddit);
} }
onContestClicked() {
this.app.analytics.trackUiClick("contest_click");
this.dialogs.showInfo(
T.mainMenu.contests.contest_01_03062020.title,
T.mainMenu.contests.contest_01_03062020.longDesc
);
}
onLanguageChooseClicked() { onLanguageChooseClicked() {
this.app.analytics.trackUiClick("choose_language"); this.app.analytics.trackUiClick("choose_language");
const setting = /** @type {EnumSetting} */ (getApplicationSettingById("language")); const setting = /** @type {EnumSetting} */ (getApplicationSettingById("language"));

View File

@ -37,7 +37,7 @@ export class PreloadState extends GameState {
return false; return false;
} }
onEnter(payload) { onEnter() {
this.htmlElement.classList.add("prefab_LoadingState"); this.htmlElement.classList.add("prefab_LoadingState");
const elementsToRemove = ["#loadingPreload", "#fontPreload"]; const elementsToRemove = ["#loadingPreload", "#fontPreload"];
@ -52,9 +52,13 @@ export class PreloadState extends GameState {
const dialogsElement = document.body.querySelector(".modalDialogParent"); const dialogsElement = document.body.querySelector(".modalDialogParent");
this.dialogs.initializeToElement(dialogsElement); this.dialogs.initializeToElement(dialogsElement);
/** @type {HTMLElement} */
this.statusText = this.htmlElement.querySelector(".loadingStatus > .desc"); this.statusText = this.htmlElement.querySelector(".loadingStatus > .desc");
/** @type {HTMLElement} */
this.statusBar = this.htmlElement.querySelector(".loadingStatus > .bar > .inner"); this.statusBar = this.htmlElement.querySelector(".loadingStatus > .bar > .inner");
/** @type {HTMLElement} */
this.statusBarText = this.htmlElement.querySelector(".loadingStatus > .bar > .status"); this.statusBarText = this.htmlElement.querySelector(".loadingStatus > .bar > .status");
this.currentStatus = "booting"; this.currentStatus = "booting";
this.currentIndex = 0; this.currentIndex = 0;
@ -251,12 +255,12 @@ export class PreloadState extends GameState {
${this.currentStatus} failed:<br/> ${this.currentStatus} failed:<br/>
${text} ${text}
</div> </div>
<div class="supportHelp"> <div class="supportHelp">
Please send me an email with steps to reproduce and what you did before this happened: Please send me an email with steps to reproduce and what you did before this happened:
<br /><a class="email" href="mailto:${email}?subject=App%20does%20not%20launch">${email}</a> <br /><a class="email" href="mailto:${email}?subject=App%20does%20not%20launch">${email}</a>
</div> </div>
<div class="lower"> <div class="lower">
<button class="resetApp styledButton">Reset App</button> <button class="resetApp styledButton">Reset App</button>
<i>Build ${G_BUILD_VERSION} @ ${G_BUILD_COMMIT_HASH}</i> <i>Build ${G_BUILD_VERSION} @ ${G_BUILD_COMMIT_HASH}</i>

View File

@ -94,6 +94,7 @@ export class SettingsState extends TextualGameState {
initSettings() { initSettings() {
allApplicationSettings.forEach(setting => { allApplicationSettings.forEach(setting => {
/** @type {HTMLElement} */
const element = this.htmlElement.querySelector("[data-setting='" + setting.id + "']"); const element = this.htmlElement.querySelector("[data-setting='" + setting.id + "']");
setting.bind(this.app, element, this.dialogs); setting.bind(this.app, element, this.dialogs);
setting.syncValueToElement(); setting.syncValueToElement();

View File

@ -3,7 +3,7 @@
/* Basic Options */ /* Basic Options */
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, "target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */ "lib": ["DOM","ES2018"], /* Specify library files to be included in the compilation. */
"allowJs": true /* Allow javascript files to be compiled. */, "allowJs": true /* Allow javascript files to be compiled. */,
"checkJs": true /* Report errors in .js files. */, "checkJs": true /* Report errors in .js files. */,
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */

View File

@ -181,7 +181,6 @@ mainMenu:
savegameLevel: 第<x>关 savegameLevel: 第<x>关
savegameLevelUnknown: savegameLevelUnknown:
未知关卡 未知关卡
# contestOver: This contest has ended - Join the discord to get noticed about new contests!
continue: 继续游戏 continue: 继续游戏
newGame: 新游戏 newGame: 新游戏
madeBy: 作者:<author-link> madeBy: 作者:<author-link>