basic typing for window + fix typo in Palantir

pull/9726/head
ananas-dev 2021-09-04 22:54:03 +02:00
parent 0c21c89fa6
commit e87fb73652
6 changed files with 32 additions and 9 deletions

View File

@ -239,6 +239,8 @@ declare namespace Editor {
interface Window {
lichess: Lichess;
el: Element;
chrome: any;
moment: any;
Mousetrap: any;
Chessground: any;
@ -252,8 +254,29 @@ interface Window {
palantir?: {
palantir(opts: PalantirOpts): Palantir;
};
LichessChat(element: Element, opts: any): unknown;
[key: string]: any; // TODO
LichessChat(element: Element, opts: any): any;
LichessFlatpickr(element: Element, opts: any): any;
LichessNotify(element: any, opts: any): any;
LichessChallenge(element: any, opts: any): any;
LichessDasher(element: any, opts: any): any;
LichessAnalyse: any;
LichessCli: any;
LichessRound: any;
Highcharts: any;
Howler: any;
Howl: any;
stripeHandler: any;
Stripe: any;
Textcomplete: any;
UserComplete: any;
Stockfish?: any;
StockfishMv?: any;
Tagify: any;
Sortable: any;
passwordComplexity: any;
requestIdleCallback: any;
Peer: any;
signupSubmit: () => void;
}
interface Study {

View File

@ -94,7 +94,7 @@ export function view(ctrl: StudyCtrl): VNode {
vData.count = newCount;
if (canContribute && newCount > 1 && !vData.sortable) {
const makeSortable = function () {
vData.sortable = window['Sortable'].create(el, {
vData.sortable = window.Sortable.create(el, {
draggable: '.draggable',
handle: 'ontouchstart' in window ? 'span' : undefined,
onSort() {
@ -102,7 +102,7 @@ export function view(ctrl: StudyCtrl): VNode {
},
});
};
if (window['Sortable']) makeSortable();
if (window.Sortable) makeSortable();
else lichess.loadScript('javascripts/vendor/Sortable.min.js').then(makeSortable);
}
}

View File

@ -37,8 +37,8 @@ function renderPalantir(ctrl: Ctrl) {
p.loaded = true;
lichess.loadScript('javascripts/vendor/peerjs.min.js').then(() => {
lichess.loadModule('palantir').then(() => {
p.instance = window.Palantir!.palantir({
uid: ctrl.data.userId,
p.instance = window.palantir!.palantir({
uid: ctrl.data.userId!,
redraw: ctrl.redraw,
});
ctrl.redraw();

View File

@ -19,7 +19,7 @@ export function palantir(opts: PalantirOpts) {
function start() {
setState('opening');
peer = new window['Peer'](peerIdOf(opts.uid))
peer = new window.Peer(peerIdOf(opts.uid))
.on('open', () => {
setState('getting-media');
devices

View File

@ -59,7 +59,7 @@ export default function (opts: RoundOpts): void {
opts.element = element;
opts.socketSend = lichess.socket.send;
const round: RoundApi = (window['LichessRound'] as RoundMain).app(opts);
const round: RoundApi = (window.LichessRound as RoundMain).app(opts);
const chatOpts = opts.chat;
if (chatOpts) {
if (data.tournament?.top) {

View File

@ -111,7 +111,7 @@ function nextRound(ctrl: SwissCtrl): VNode | undefined {
value: ctrl.data.nextRound?.at || '',
},
hook: onInsert((el: HTMLInputElement) =>
window['LichessFlatpickr'](el, {
window.LichessFlatpickr(el, {
minDate: 'today',
maxDate: new Date(Date.now() + 1000 * 3600 * 24 * 31),
dateFormat: 'Z',