no implicit any

materials
Valerie 2021-06-26 13:07:11 -04:00
parent 206e5852a0
commit 8a9f6096ee
15 changed files with 36 additions and 18 deletions

View File

@ -9,8 +9,10 @@
"@types/bonjour": "^3.5.8",
"@types/chai": "^4.2.19",
"@types/faker": "^5.5.6",
"@types/fs-extra": "^9.0.11",
"@types/mocha": "^8.2.2",
"@types/uuid": "^8.3.0",
"@types/ws": "^7.4.5",
"bonjour": "^3.5.0",
"chai": "^4.3.4",
"chalk": "^4.1.1",

View File

@ -9,7 +9,7 @@ import { render, Renderable, setTitle, start } from './ui/UI.js';
import { ready } from './multiplayer/mDNS.js';
import faker from 'faker';
let game = null;
let game: Game = null;
export class Game extends Frigid implements Tickable, Renderable {
pawns: Pawn[] = [];
@ -47,7 +47,7 @@ export class Game extends Frigid implements Tickable, Renderable {
});
}
advanceSelection(number) {
advanceSelection(number: number) {
let index = this.pawns.indexOf(this.selected);
this.selected = this.pawns[Math.min(Math.max(index + number, 0), this.pawns.length - 1)];
}

View File

@ -21,7 +21,7 @@ export class TaskList extends Serializable implements Renderable {
this.tasks = [...this.tasks, task];
}
removeTask(task) {
removeTask(task: TaskState<any>) {
this.tasks = this.tasks.filter(v => v !== task);
}

View File

@ -118,7 +118,7 @@ export default class Time extends Serializable implements Renderable {
setTimeout(this.doTick.bind(this), 0);
}
advanceTime(seconds) {
advanceTime(seconds: number) {
this.minute += seconds / 60;
this.normalize()
}

View File

@ -29,7 +29,7 @@ export type GiftMessage = {
export default network;
export async function ready(name) {
export async function ready(name: string) {
const port = await getPort({port: getPort.makeRange(52300, 52399)});
mdns.publish({
type: 'dfi',
@ -39,7 +39,7 @@ export async function ready(name) {
const wss = new WebSocket.Server({ port });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
const {pawns: pawnJsons, from} = JSON.parse(message);
const {pawns: pawnJsons, from} = JSON.parse(message.toString());
const pawns = [];
for(const pawnJson of pawnJsons) {
const pawn: Pawn = Pawn.fromJson(pawnJson);

View File

@ -15,7 +15,7 @@ export class Item<Data> extends Serializable {
id: ItemID = '';
props: Map<string, PropertyValue> = new Map();
setName(name) {
setName(name: string) {
this.name = name;
this.register(false);
return this;
@ -35,7 +35,7 @@ export class Item<Data> extends Serializable {
}
setProperty(prop: ItemProperty, value: any) {
this.props[prop.name] = value;
this.props.set(prop.name, value);
return this;
}

1
src/types.d.ts vendored 100644
View File

@ -0,0 +1 @@
declare module "neo-blessed";

View File

@ -25,7 +25,7 @@ export class GiftPopup {
tags: true,
...boxStyle(),
});
this.box.on('keypress', (evt, key) => {
this.box.on('keypress', (evt: {}, key: {full: string}) => {
if(key.full === 'enter') {
this.send();
} if(key.full === 'escape' || key.full === 'enter') {

View File

@ -13,7 +13,7 @@ import { View } from './View.js';
import { ActionsView } from './view/ActionsView.js';
import { tasks } from '@tasks';
const clamp = (min, max, value) => Math.min(Math.max(value, min), max);
const clamp = (min: number, max: number, value: number) => Math.min(Math.max(value, min), max);
// TODO move KeypressAcceptor to ui something idk
export interface KeypressAcceptor {
@ -46,7 +46,7 @@ export class Menu implements Renderable {
}
constructor() {
panels.right.on('keypress', (evt, key) => {
panels.right.on('keypress', (evt: {}, key: {full: string}) => {
if (key.full === 'left') {
this.regressView();

View File

@ -21,7 +21,7 @@ export class PawnDetails {
tags: true,
...boxStyle(),
});
this.box.on('keypress', (evt, key) => {
this.box.on('keypress', (evt: {}, key: {full: string}) => {
if(key.full === 'escape' || key.full === 'enter') {
Game.current.clock.start();
panels.screen.remove(this.box);

View File

@ -7,11 +7,11 @@ import { panels } from './UI.js';
export class Popup {
box;
static show(content) {
static show(content: string) {
new Popup(content)
}
private constructor(content) {
private constructor(content: string) {
this.box = blessed.box({
top: 'center',
left: 'center',
@ -21,7 +21,7 @@ export class Popup {
tags: true,
...boxStyle(),
});
this.box.on('keypress', (evt, key) => {
this.box.on('keypress', (evt: {}, key: {full: string}) => {
if(key.full === 'escape' || key.full === 'enter') {
Game.current.clock.start();
panels.screen.remove(this.box);

View File

@ -99,7 +99,7 @@ export function start() {
process.stdout.write(ansi.cursor.hide);
screen.key(['C-c'], function(ch, key) {
screen.key(['C-c'], function() {
process.stdout.write(ansi.cursor.show);
setTimeout(_ => {
process.exit(0);

View File

@ -12,7 +12,7 @@ export class ActionsView extends View {
this.name = 'Actions';
}
keypress(key) {
keypress(key: {full: string}) {
if(key.full === 'up') {
this.actionIdx --;
} else if (key.full === 'down') {

View File

@ -13,7 +13,8 @@
"@tasks": ["./src/registries/Tasks"],
"@items": ["./src/registries/Items"],
"@game": ["./src/Game"]
}
},
"noImplicitAny": true
},
"include": [
"src/**/*.ts",

View File

@ -35,6 +35,13 @@
version "5.5.6"
resolved "https://registry.yarnpkg.com/@types/faker/-/faker-5.5.6.tgz#039b700a9d8ad9150ecc842bf5e717e2027b6f75"
"@types/fs-extra@^9.0.11":
version "9.0.11"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.11.tgz#8cc99e103499eab9f347dbc6ca4e99fb8d2c2b87"
integrity sha512-mZsifGG4QeQ7hlkhO56u7zt/ycBgGxSVsFI/6lGTU34VtwkiqrrSDgw0+ygs8kFGWcXnFQWMrzF2h7TtDFNixA==
dependencies:
"@types/node" "*"
"@types/minimatch@^3.0.3", "@types/minimatch@^3.0.4":
version "3.0.4"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.4.tgz#f0ec25dbf2f0e4b18647313ac031134ca5b24b21"
@ -53,6 +60,13 @@
version "8.3.0"
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.0.tgz#215c231dff736d5ba92410e6d602050cce7e273f"
"@types/ws@^7.4.5":
version "7.4.5"
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.5.tgz#8ff0f7efcd8fea19f51f9dd66cb8b498d172a752"
integrity sha512-8mbDgtc8xpxDDem5Gwj76stBDJX35KQ3YBoayxlqUQcL5BZUthiqP/VQ4PQnLHqM4PmlbyO74t98eJpURO+gPA==
dependencies:
"@types/node" "*"
"@ungap/promise-all-settled@1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44"