[TS] Enable strict mode (#3136)

This commit is contained in:
Chenlei Hu
2025-03-18 22:57:17 -04:00
committed by GitHub
parent 44edec7ad2
commit a049e9ae2d
64 changed files with 924 additions and 781 deletions

View File

@@ -1,4 +1,3 @@
// @ts-strict-ignore
export function getFromFlacBuffer(buffer: ArrayBuffer): Record<string, string> {
const dataView = new DataView(buffer)
@@ -6,6 +5,7 @@ export function getFromFlacBuffer(buffer: ArrayBuffer): Record<string, string> {
const signature = String.fromCharCode(...new Uint8Array(buffer, 0, 4))
if (signature !== 'fLaC') {
console.error('Not a valid FLAC file')
// @ts-expect-error fixme ts strict error
return
}
@@ -29,6 +29,7 @@ export function getFromFlacBuffer(buffer: ArrayBuffer): Record<string, string> {
if (isLastBlock) break
}
// @ts-expect-error fixme ts strict error
return vorbisComment
}
@@ -36,6 +37,7 @@ export function getFromFlacFile(file: File): Promise<Record<string, string>> {
return new Promise((r) => {
const reader = new FileReader()
reader.onload = function (event) {
// @ts-expect-error fixme ts strict error
const arrayBuffer = event.target.result as ArrayBuffer
r(getFromFlacBuffer(arrayBuffer))
}
@@ -64,6 +66,7 @@ function parseVorbisComment(dataView: DataView): Record<string, string> {
const ind = comment.indexOf('=')
const key = comment.substring(0, ind)
// @ts-expect-error fixme ts strict error
comments[key] = comment.substring(ind + 1)
}

View File

@@ -1,4 +1,3 @@
// @ts-strict-ignore
export function getFromPngBuffer(buffer: ArrayBuffer) {
// Get the PNG data as a Uint8Array
const pngData = new Uint8Array(buffer)
@@ -46,6 +45,7 @@ export function getFromPngFile(file: File) {
return new Promise<Record<string, string>>((r) => {
const reader = new FileReader()
reader.onload = (event) => {
// @ts-expect-error fixme ts strict error
r(getFromPngBuffer(event.target.result as ArrayBuffer))
}