Fixing Svelte-check errors

This commit is contained in:
David Négrier 2021-06-15 18:34:11 +02:00
parent 085a4d41fd
commit 0afdbf7040
15 changed files with 79 additions and 44 deletions

View File

@ -58,7 +58,7 @@
"test": "TS_NODE_PROJECT=\"tsconfig-for-jasmine.json\" ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json", "test": "TS_NODE_PROJECT=\"tsconfig-for-jasmine.json\" ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json",
"lint": "node_modules/.bin/eslint src/ . --ext .ts", "lint": "node_modules/.bin/eslint src/ . --ext .ts",
"fix": "node_modules/.bin/eslint --fix src/ . --ext .ts", "fix": "node_modules/.bin/eslint --fix src/ . --ext .ts",
"svelte-check-watch": "svelte-check --fail-on-warnings --compiler-warnings \"a11y-no-onchange:ignore,a11y-autofocus:ignore\" --watch", "svelte-check-watch": "svelte-check --fail-on-warnings --fail-on-hints --compiler-warnings \"a11y-no-onchange:ignore,a11y-autofocus:ignore\" --watch",
"svelte-check": "svelte-check --fail-on-warnings --compiler-warnings \"a11y-no-onchange:ignore,a11y-autofocus:ignore\"" "svelte-check": "svelte-check --fail-on-warnings --fail-on-hints --compiler-warnings \"a11y-no-onchange:ignore,a11y-autofocus:ignore\""
} }
} }

View File

@ -1,6 +1,4 @@
<script lang="typescript"> <script lang="typescript">
import MenuIcon from "./Menu/MenuIcon.svelte";
import {menuIconVisible} from "../Stores/MenuStore";
import {enableCameraSceneVisibilityStore, gameOverlayVisibilityStore} from "../Stores/MediaStore"; import {enableCameraSceneVisibilityStore, gameOverlayVisibilityStore} from "../Stores/MediaStore";
import CameraControls from "./CameraControls.svelte"; import CameraControls from "./CameraControls.svelte";
import MyCamera from "./MyCamera.svelte"; import MyCamera from "./MyCamera.svelte";
@ -17,7 +15,7 @@
import VisitCard from "./VisitCard/VisitCard.svelte"; import VisitCard from "./VisitCard/VisitCard.svelte";
import {requestVisitCardsStore} from "../Stores/GameStore"; import {requestVisitCardsStore} from "../Stores/GameStore";
import {Game} from "../Phaser/Game/Game"; import type {Game} from "../Phaser/Game/Game";
import {helpCameraSettingsVisibleStore} from "../Stores/HelpCameraSettingsStore"; import {helpCameraSettingsVisibleStore} from "../Stores/HelpCameraSettingsStore";
import HelpCameraSettingsPopup from "./HelpCameraSettings/HelpCameraSettingsPopup.svelte"; import HelpCameraSettingsPopup from "./HelpCameraSettings/HelpCameraSettingsPopup.svelte";
import AudioPlaying from "./UI/AudioPlaying.svelte"; import AudioPlaying from "./UI/AudioPlaying.svelte";
@ -74,7 +72,7 @@
{/if} {/if}
{#if $helpCameraSettingsVisibleStore} {#if $helpCameraSettingsVisibleStore}
<div> <div>
<HelpCameraSettingsPopup game={ game }></HelpCameraSettingsPopup> <HelpCameraSettingsPopup></HelpCameraSettingsPopup>
</div> </div>
{/if} {/if}
{#if $requestVisitCardsStore} {#if $requestVisitCardsStore}

View File

@ -1,10 +1,10 @@
<script lang="typescript"> <script lang="typescript">
import { Game } from "../../Phaser/Game/Game"; import type { Game } from "../../Phaser/Game/Game";
import { CustomizeSceneName } from "../../Phaser/Login/CustomizeScene"; import {CustomizeScene, CustomizeSceneName} from "../../Phaser/Login/CustomizeScene";
export let game: Game; export let game: Game;
const customCharacterScene = game.scene.getScene(CustomizeSceneName); const customCharacterScene = game.scene.getScene(CustomizeSceneName) as CustomizeScene;
let activeRow = customCharacterScene.activeRow; let activeRow = customCharacterScene.activeRow;
function selectLeft() { function selectLeft() {

View File

@ -1,5 +1,5 @@
<script lang="typescript"> <script lang="typescript">
import {Game} from "../../Phaser/Game/Game"; import type {Game} from "../../Phaser/Game/Game";
import {EnableCameraScene, EnableCameraSceneName} from "../../Phaser/Login/EnableCameraScene"; import {EnableCameraScene, EnableCameraSceneName} from "../../Phaser/Login/EnableCameraScene";
import { import {
audioConstraintStore, audioConstraintStore,
@ -15,8 +15,8 @@
import microphoneImg from "../images/microphone.svg"; import microphoneImg from "../images/microphone.svg";
export let game: Game; export let game: Game;
let selectedCamera : string|null = null; let selectedCamera : string|undefined = undefined;
let selectedMicrophone : string|null = null; let selectedMicrophone : string|undefined = undefined;
const enableCameraScene = game.scene.getScene(EnableCameraSceneName) as EnableCameraScene; const enableCameraScene = game.scene.getScene(EnableCameraSceneName) as EnableCameraScene;
@ -24,10 +24,10 @@
enableCameraScene.login(); enableCameraScene.login();
} }
function srcObject(node, stream) { function srcObject(node: HTMLVideoElement, stream: MediaStream) {
node.srcObject = stream; node.srcObject = stream;
return { return {
update(newStream) { update(newStream: MediaStream) {
if (node.srcObject != newStream) { if (node.srcObject != newStream) {
node.srcObject = newStream node.srcObject = newStream
} }
@ -53,8 +53,8 @@
} }
} else { } else {
stream = null; stream = null;
selectedCamera = null; selectedCamera = undefined;
selectedMicrophone = null; selectedMicrophone = undefined;
} }
}); });
@ -79,7 +79,7 @@
<section class="text-center"> <section class="text-center">
<h2>Turn on your camera and microphone</h2> <h2>Turn on your camera and microphone</h2>
</section> </section>
{#if $localStreamStore.stream} {#if $localStreamStore.type === 'success' && $localStreamStore.stream}
<video class="myCamVideoSetup" use:srcObject={$localStreamStore.stream} autoplay muted playsinline></video> <video class="myCamVideoSetup" use:srcObject={$localStreamStore.stream} autoplay muted playsinline></video>
{:else } {:else }
<div class="webrtcsetup"> <div class="webrtcsetup">

View File

@ -8,7 +8,7 @@
const NB_BARS = 20; const NB_BARS = 20;
let timeout; let timeout: ReturnType<typeof setTimeout>;
const soundMeter = new SoundMeter(); const soundMeter = new SoundMeter();
let display = false; let display = false;

View File

@ -1,14 +1,13 @@
<script lang="typescript"> <script lang="typescript">
import {Game} from "../../Phaser/Game/Game"; import type {Game} from "../../Phaser/Game/Game";
import {LoginSceneName} from "../../Phaser/Login/LoginScene"; import {LoginScene, LoginSceneName} from "../../Phaser/Login/LoginScene";
import {DISPLAY_TERMS_OF_USE, MAX_USERNAME_LENGTH} from "../../Enum/EnvironmentVariable"; import {DISPLAY_TERMS_OF_USE, MAX_USERNAME_LENGTH} from "../../Enum/EnvironmentVariable";
import logoImg from "../images/logo.png"; import logoImg from "../images/logo.png";
import {gameManager} from "../../Phaser/Game/GameManager"; import {gameManager} from "../../Phaser/Game/GameManager";
import {maxUserNameLength} from "../../Connexion/LocalUser";
export let game: Game; export let game: Game;
const loginScene = game.scene.getScene(LoginSceneName); const loginScene = game.scene.getScene(LoginSceneName) as LoginScene;
let name = gameManager.getPlayerName() || ''; let name = gameManager.getPlayerName() || '';
let startValidating = false; let startValidating = false;

View File

@ -3,10 +3,10 @@
import SoundMeterWidget from "./SoundMeterWidget.svelte"; import SoundMeterWidget from "./SoundMeterWidget.svelte";
import {onDestroy} from "svelte"; import {onDestroy} from "svelte";
function srcObject(node, stream) { function srcObject(node: HTMLVideoElement, stream: MediaStream) {
node.srcObject = stream; node.srcObject = stream;
return { return {
update(newStream) { update(newStream: MediaStream) {
if (node.srcObject != newStream) { if (node.srcObject != newStream) {
node.srcObject = newStream node.srcObject = newStream
} }
@ -38,9 +38,9 @@
<div> <div>
<div class="video-container div-myCamVideo" class:hide={!$localStreamStore.constraints.video}> <div class="video-container div-myCamVideo" class:hide={!$localStreamStore.constraints.video}>
{#if $localStreamStore.type === "success" && $localStreamStore.stream }
<video class="myCamVideo" use:srcObject={$localStreamStore.stream} autoplay muted playsinline></video> <video class="myCamVideo" use:srcObject={$localStreamStore.stream} autoplay muted playsinline></video>
<!-- {#if stream}
<SoundMeterWidget stream={stream}></SoundMeterWidget> <SoundMeterWidget stream={stream}></SoundMeterWidget>
{/if} --> {/if}
</div> </div>
</div> </div>

View File

@ -1,10 +1,10 @@
<script lang="typescript"> <script lang="typescript">
import {Game} from "../../Phaser/Game/Game"; import type {Game} from "../../Phaser/Game/Game";
import {SelectCompanionSceneName} from "../../Phaser/Login/SelectCompanionScene"; import {SelectCompanionScene, SelectCompanionSceneName} from "../../Phaser/Login/SelectCompanionScene";
export let game: Game; export let game: Game;
const selectCompanionScene = game.scene.getScene(SelectCompanionSceneName); const selectCompanionScene = game.scene.getScene(SelectCompanionSceneName) as SelectCompanionScene;
function selectLeft() { function selectLeft() {
selectCompanionScene.moveToLeft(); selectCompanionScene.moveToLeft();

View File

@ -8,7 +8,7 @@
const NB_BARS = 5; const NB_BARS = 5;
let timeout; let timeout: ReturnType<typeof setTimeout>;
const soundMeter = new SoundMeter(); const soundMeter = new SoundMeter();
let display = false; let display = false;

View File

@ -2,7 +2,7 @@
import { fly } from 'svelte/transition'; import { fly } from 'svelte/transition';
import megaphoneImg from "./images/megaphone.svg"; import megaphoneImg from "./images/megaphone.svg";
import {soundPlayingStore} from "../../Stores/SoundPlayingStore"; import {soundPlayingStore} from "../../Stores/SoundPlayingStore";
import {afterUpdate, onMount} from "svelte"; import {afterUpdate} from "svelte";
export let url: string; export let url: string;
let audio: HTMLAudioElement; let audio: HTMLAudioElement;

View File

@ -7,7 +7,7 @@
let w = '500px'; let w = '500px';
let h = '250px'; let h = '250px';
let hidden = true; let hidden = true;
let cvIframe; let cvIframe: HTMLIFrameElement;
function closeCard() { function closeCard() {
requestVisitCardsStore.set(null); requestVisitCardsStore.set(null);

View File

@ -1,10 +1,10 @@
<script lang="typescript"> <script lang="typescript">
import { Game } from "../../Phaser/Game/Game"; import type { Game } from "../../Phaser/Game/Game";
import { SelectCharacterSceneName } from "../../Phaser/Login/SelectCharacterScene"; import {SelectCharacterScene, SelectCharacterSceneName} from "../../Phaser/Login/SelectCharacterScene";
export let game: Game; export let game: Game;
const selectCharacterScene = game.scene.getScene(SelectCharacterSceneName); const selectCharacterScene = game.scene.getScene(SelectCharacterSceneName) as SelectCharacterScene;
function selectLeft() { function selectLeft() {
selectCharacterScene.moveToLeft(); selectCharacterScene.moveToLeft();

View File

@ -263,7 +263,7 @@ export class CustomizeScene extends AbstractCharacterScene {
this.Rectangle.y = this.cameras.main.worldView.y + this.cameras.main.height / 3; this.Rectangle.y = this.cameras.main.worldView.y + this.cameras.main.height / 3;
} }
private nextSceneToCamera(){ public nextSceneToCamera(){
const layers: string[] = []; const layers: string[] = [];
let i = 0; let i = 0;
for (const layerItem of this.selectedLayers) { for (const layerItem of this.selectedLayers) {
@ -284,7 +284,7 @@ export class CustomizeScene extends AbstractCharacterScene {
customCharacterSceneVisibleStore.set(false); customCharacterSceneVisibleStore.set(false);
} }
private backToPreviousScene(){ public backToPreviousScene(){
this.scene.sleep(CustomizeSceneName); this.scene.sleep(CustomizeSceneName);
waScaleManager.restoreZoom(); waScaleManager.restoreZoom();
this.scene.run(SelectCharacterSceneName); this.scene.run(SelectCharacterSceneName);

View File

@ -92,7 +92,7 @@ export class SelectCharacterScene extends AbstractCharacterScene {
}); });
} }
protected nextSceneToCameraScene(): void { public nextSceneToCameraScene(): void {
if (this.selectedPlayer !== null && !areCharacterLayersValid([this.selectedPlayer.texture.key])) { if (this.selectedPlayer !== null && !areCharacterLayersValid([this.selectedPlayer.texture.key])) {
return; return;
} }
@ -108,7 +108,7 @@ export class SelectCharacterScene extends AbstractCharacterScene {
this.events.removeListener('wake'); this.events.removeListener('wake');
} }
protected nextSceneToCustomizeScene(): void { public nextSceneToCustomizeScene(): void {
if (this.selectedPlayer !== null && !areCharacterLayersValid([this.selectedPlayer.texture.key])) { if (this.selectedPlayer !== null && !areCharacterLayersValid([this.selectedPlayer.texture.key])) {
return; return;
} }
@ -165,7 +165,7 @@ export class SelectCharacterScene extends AbstractCharacterScene {
this.updateSelectedPlayer(); this.updateSelectedPlayer();
} }
protected moveToLeft(){ public moveToLeft(){
if(this.currentSelectUser === 0){ if(this.currentSelectUser === 0){
return; return;
} }
@ -173,7 +173,7 @@ export class SelectCharacterScene extends AbstractCharacterScene {
this.moveUser(); this.moveUser();
} }
protected moveToRight(){ public moveToRight(){
if(this.currentSelectUser === (this.players.length - 1)){ if(this.currentSelectUser === (this.players.length - 1)){
return; return;
} }

38
front/src/ambient.d.ts vendored Normal file
View File

@ -0,0 +1,38 @@
/**
* These declarations tell TypeScript that we allow import of images, e.g.
* ```
<script lang='ts'>
import successkid from 'images/successkid.jpg';
</script>
<img src="{successkid}">
```
*/
declare module "*.gif" {
const value: string;
export = value;
}
declare module "*.jpg" {
const value: string;
export = value;
}
declare module "*.jpeg" {
const value: string;
export = value;
}
declare module "*.png" {
const value: string;
export = value;
}
declare module "*.svg" {
const value: string;
export = value;
}
declare module "*.webp" {
const value: string;
export = value;
}