Fixed most of TypeScript errors for TS 3.1.2

This commit is contained in:
Eduard Urbach 2018-10-10 17:42:23 +09:00
parent d1987e9c60
commit 1829c2cab9
6 changed files with 14 additions and 106 deletions

View File

@ -195,7 +195,7 @@ export function searchBySpeech(arn: AnimeNotifier, element: HTMLElement) {
let searchInput = document.getElementById("search") as HTMLInputElement
let oldPlaceholder = searchInput.placeholder
let SpeechRecognition: SpeechRecognitionStatic = window["SpeechRecognition"] || window["webkitSpeechRecognition"]
let SpeechRecognition: any = window["SpeechRecognition"] || window["webkitSpeechRecognition"]
recognition = new SpeechRecognition()
recognition.continuous = false
recognition.interimResults = false

View File

@ -23,10 +23,12 @@ export default class Analytics {
}
if("connection" in navigator) {
let connection = navigator["connection"] as any
analytics.connection = {
downLink: navigator["connection"].downlink,
roundTripTime: navigator["connection"].rtt,
effectiveType: navigator["connection"].effectiveType
downLink: connection.downlink,
roundTripTime: connection.rtt,
effectiveType: connection.effectiveType
}
}

View File

@ -1019,7 +1019,8 @@ export default class AnimeNotifier {
// Disallow Enter key in contenteditables and make it blur the element instead
if(e.keyCode === 13) {
if("blur" in activeElement) {
activeElement["blur"]()
let blur = activeElement["blur"] as Function
blur()
}
return preventDefault()

View File

@ -193,7 +193,7 @@ export default class Application {
this.content.innerHTML = html
}
markActiveLinks(links?: NodeListOf<HTMLAnchorElement>) {
markActiveLinks(links?: HTMLCollectionOf<HTMLAnchorElement>) {
if(!links) {
links = document.getElementsByTagName("a")
}
@ -211,7 +211,7 @@ export default class Application {
}
}
ajaxify(links?: NodeListOf<HTMLAnchorElement>) {
ajaxify(links?: HTMLCollectionOf<HTMLAnchorElement>) {
if(!links) {
links = document.getElementsByTagName("a")
}
@ -241,10 +241,10 @@ export default class Application {
return
}
let url = this.getAttribute("href")
e.preventDefault()
let url = (this as HTMLAnchorElement).getAttribute("href")
if(!url || url === self.currentPath) {
return
}

View File

@ -1,96 +0,0 @@
// Type definitions for Web Speech API
// Project: https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
// Definitions by: SaschaNaz <https://github.com/saschanaz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// Spec version: 19 October 2012
// Errata version: 6 June 2014
// Corrected unofficial spec version: 6 June 2014
interface SpeechRecognition extends EventTarget {
grammars: SpeechGrammarList;
lang: string;
continuous: boolean;
interimResults: boolean;
maxAlternatives: number;
serviceURI: string;
start(): void;
stop(): void;
abort(): void;
onaudiostart: (ev: Event) => any;
onsoundstart: (ev: Event) => any;
onspeechstart: (ev: Event) => any;
onspeechend: (ev: Event) => any;
onsoundend: (ev: Event) => any;
onaudioend: (ev: Event) => any;
onresult: (ev: SpeechRecognitionEvent) => any;
onnomatch: (ev: SpeechRecognitionEvent) => any;
onerror: (ev: SpeechRecognitionError) => any;
onstart: (ev: Event) => any;
onend: (ev: Event) => any;
}
interface SpeechRecognitionStatic {
prototype: SpeechRecognition;
new (): SpeechRecognition;
}
declare var SpeechRecognition: SpeechRecognitionStatic;
declare var webkitSpeechRecognition: SpeechRecognitionStatic;
interface SpeechRecognitionError extends Event {
error: string;
message: string;
}
interface SpeechRecognitionAlternative {
transcript: string;
confidence: number;
}
interface SpeechRecognitionResult {
length: number;
item(index: number): SpeechRecognitionAlternative;
[index: number]: SpeechRecognitionAlternative;
/* Errata 02 */
isFinal: boolean;
}
interface SpeechRecognitionResultList {
length: number;
item(index: number): SpeechRecognitionResult;
[index: number]: SpeechRecognitionResult;
}
interface SpeechRecognitionEvent extends Event {
resultIndex: number;
results: SpeechRecognitionResultList;
interpretation: any;
emma: Document;
}
interface SpeechGrammar {
src: string;
weight: number;
}
interface SpeechGrammarStatic {
prototype: SpeechGrammar;
new (): SpeechGrammar;
}
declare var SpeechGrammar: SpeechGrammarStatic;
declare var webkitSpeechGrammar: SpeechGrammarStatic;
interface SpeechGrammarList {
length: number;
item(index: number): SpeechGrammar;
[index: number]: SpeechGrammar;
addFromURI(src: string, weight: number): void;
addFromString(string: string, weight: number): void;
}
interface SpeechGrammarListStatic {
prototype: SpeechGrammarList;
new (): SpeechGrammarList;
}
declare var SpeechGrammarList: SpeechGrammarListStatic;
declare var webkitSpeechGrammarList: SpeechGrammarListStatic;

View File

@ -1,6 +1,7 @@
export function requestIdleCallback(func: Function) {
if("requestIdleCallback" in window) {
window["requestIdleCallback"](func)
let requestIdleCallback = window["requestIdleCallback"] as Function
requestIdleCallback(func)
} else {
func()
}