mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-19 10:05:38 +02:00
refactor: make noImplicitAny true (#17083)
* wip * Update emojis.emoji.vue * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update manager.ts * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update analytics.ts
This commit is contained in:
@@ -14,7 +14,7 @@ export async function lookupUser() {
|
||||
});
|
||||
if (canceled || result == null) return;
|
||||
|
||||
const show = (user) => {
|
||||
const show = (user: Misskey.entities.UserDetailed) => {
|
||||
os.pageWindow(`/admin/user/${user.id}`);
|
||||
};
|
||||
|
||||
@@ -71,12 +71,8 @@ export async function lookupFile() {
|
||||
});
|
||||
if (canceled) return;
|
||||
|
||||
const show = (file) => {
|
||||
os.pageWindow(`/admin/file/${file.id}`);
|
||||
};
|
||||
|
||||
misskeyApi('admin/drive/show-file', q.startsWith('http://') || q.startsWith('https://') ? { url: q.trim() } : { fileId: q.trim() }).then(file => {
|
||||
show(file);
|
||||
os.pageWindow(`/admin/file/${file.id}`);
|
||||
}).catch(err => {
|
||||
if (err.code === 'NO_SUCH_FILE') {
|
||||
os.alert({
|
||||
|
||||
@@ -194,7 +194,7 @@ export class Autocomplete {
|
||||
this.currentType = type;
|
||||
|
||||
//#region サジェストを表示すべき位置を計算
|
||||
const caretPosition = getCaretCoordinates(this.textarea, this.textarea.selectionStart);
|
||||
const caretPosition = getCaretCoordinates(this.textarea, this.textarea.selectionStart ?? 0);
|
||||
|
||||
const rect = this.textarea.getBoundingClientRect();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ export const chartVLine = (vLineColor: string) => ({
|
||||
const tooltip = chart.tooltip as any;
|
||||
if (tooltip?._active?.length) {
|
||||
const ctx = chart.ctx;
|
||||
const xs = tooltip._active.map(a => a.element.x);
|
||||
const xs = tooltip._active.map((a: any) => a.element.x) as number[];
|
||||
const x = xs.reduce((a, b) => a + b, 0) / xs.length;
|
||||
const topY = chart.scales.y.top;
|
||||
const bottomY = chart.scales.y.bottom;
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
interface StringPageVar {
|
||||
name: string,
|
||||
type: 'string',
|
||||
value: string
|
||||
}
|
||||
|
||||
interface NumberPageVar {
|
||||
name: string,
|
||||
type: 'number',
|
||||
value: number
|
||||
}
|
||||
|
||||
interface BooleanPageVar {
|
||||
name: string,
|
||||
type: 'boolean',
|
||||
value: boolean
|
||||
}
|
||||
|
||||
type PageVar = StringPageVar | NumberPageVar | BooleanPageVar;
|
||||
|
||||
export function collectPageVars(content): PageVar[] {
|
||||
const pageVars: PageVar[] = [];
|
||||
const collect = (xs: any[]): void => {
|
||||
for (const x of xs) {
|
||||
if (x.type === 'textInput') {
|
||||
pageVars.push({
|
||||
name: x.name,
|
||||
type: 'string',
|
||||
value: x.default || '',
|
||||
});
|
||||
} else if (x.type === 'textareaInput') {
|
||||
pageVars.push({
|
||||
name: x.name,
|
||||
type: 'string',
|
||||
value: x.default || '',
|
||||
});
|
||||
} else if (x.type === 'numberInput') {
|
||||
pageVars.push({
|
||||
name: x.name,
|
||||
type: 'number',
|
||||
value: x.default || 0,
|
||||
});
|
||||
} else if (x.type === 'switch') {
|
||||
pageVars.push({
|
||||
name: x.name,
|
||||
type: 'boolean',
|
||||
value: x.default || false,
|
||||
});
|
||||
} else if (x.type === 'counter') {
|
||||
pageVars.push({
|
||||
name: x.name,
|
||||
type: 'number',
|
||||
value: 0,
|
||||
});
|
||||
} else if (x.type === 'radioButton') {
|
||||
pageVars.push({
|
||||
name: x.name,
|
||||
type: 'string',
|
||||
value: x.default || '',
|
||||
});
|
||||
} else if (x.children) {
|
||||
collect(x.children);
|
||||
}
|
||||
}
|
||||
};
|
||||
collect(content);
|
||||
return pageVars;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ export function deepEqual(a: JsonLike, b: JsonLike): boolean {
|
||||
if (aks.length !== bks.length) return false;
|
||||
for (let i = 0; i < aks.length; i++) {
|
||||
const k = aks[i];
|
||||
if (!deepEqual(a[k], (b as { [key: string]: JsonLike })[k])) return false;
|
||||
if (!deepEqual((a as { [key: string]: JsonLike })[k], (b as { [key: string]: JsonLike })[k])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export default (parent, child, checkSame = true) => {
|
||||
export function elementContains(parent: Element | null, child: Element | null, checkSame = true) {
|
||||
if (parent === null || child === null) return false;
|
||||
if (checkSame && parent === child) return true;
|
||||
let node = child.parentNode;
|
||||
while (node) {
|
||||
@@ -11,4 +12,4 @@ export default (parent, child, checkSame = true) => {
|
||||
node = node.parentNode;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
@@ -84,7 +84,7 @@ export interface ArrayFormItem extends FormItemBase {
|
||||
export interface ButtonFormItem extends FormItemBase {
|
||||
type: 'button';
|
||||
content?: string;
|
||||
action: (ev: MouseEvent, v: any) => void;
|
||||
action: (ev: PointerEvent, v: any) => void;
|
||||
}
|
||||
|
||||
export interface DriveFileFormItem extends FormItemBase {
|
||||
@@ -126,23 +126,23 @@ type NonNullableIfRequired<T, Item extends FormItem> =
|
||||
type GetItemType<Item extends FormItem> =
|
||||
Item extends StringFormItem
|
||||
? NonNullableIfRequired<InferDefault<Item, string>, Item>
|
||||
: Item extends NumberFormItem
|
||||
? NonNullableIfRequired<InferDefault<Item, number>, Item>
|
||||
: Item extends BooleanFormItem
|
||||
? boolean
|
||||
: Item extends RadioFormItem
|
||||
? GetRadioItemType<Item>
|
||||
: Item extends RangeFormItem
|
||||
? NonNullableIfRequired<InferDefault<Item, number>, Item>
|
||||
: Item extends EnumFormItem
|
||||
? GetEnumItemType<Item>
|
||||
: Item extends ArrayFormItem
|
||||
? NonNullableIfRequired<InferDefault<Item, unknown[]>, Item>
|
||||
: Item extends ObjectFormItem
|
||||
? NonNullableIfRequired<InferDefault<Item, Record<string, unknown>>, Item>
|
||||
: Item extends DriveFileFormItem
|
||||
? Misskey.entities.DriveFile | undefined
|
||||
: never;
|
||||
: Item extends NumberFormItem
|
||||
? NonNullableIfRequired<InferDefault<Item, number>, Item>
|
||||
: Item extends BooleanFormItem
|
||||
? boolean
|
||||
: Item extends RadioFormItem
|
||||
? GetRadioItemType<Item>
|
||||
: Item extends RangeFormItem
|
||||
? NonNullableIfRequired<InferDefault<Item, number>, Item>
|
||||
: Item extends EnumFormItem
|
||||
? GetEnumItemType<Item>
|
||||
: Item extends ArrayFormItem
|
||||
? NonNullableIfRequired<InferDefault<Item, unknown[]>, Item>
|
||||
: Item extends ObjectFormItem
|
||||
? NonNullableIfRequired<InferDefault<Item, Record<string, unknown>>, Item>
|
||||
: Item extends DriveFileFormItem
|
||||
? Misskey.entities.DriveFile | undefined
|
||||
: never;
|
||||
|
||||
export type GetFormResultType<F extends Form> = {
|
||||
[P in keyof F]: GetItemType<F[P]>;
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { defineAsyncComponent } from 'vue';
|
||||
import { genId } from '@/utility/id.js';
|
||||
import { url } from '@@/js/config.js';
|
||||
import { defaultEmbedParams, embedRouteWithScrollbar } from '@@/js/embed-page.js';
|
||||
import type { EmbedParams, EmbeddableEntity } from '@@/js/embed-page.js';
|
||||
import { genId } from '@/utility/id.js';
|
||||
import * as os from '@/os.js';
|
||||
import { copyToClipboard } from '@/utility/copy-to-clipboard.js';
|
||||
|
||||
@@ -21,19 +21,20 @@ export function normalizeEmbedParams(params: EmbedParams): Record<string, string
|
||||
// paramsのvalueをすべてstringに変換。undefinedやnullはプロパティごと消す
|
||||
const normalizedParams: Record<string, string> = {};
|
||||
for (const key in params) {
|
||||
const k = key as keyof EmbedParams;
|
||||
// デフォルトの値と同じならparamsに含めない
|
||||
if (params[key] == null || params[key] === defaultEmbedParams[key]) {
|
||||
if (params[k] == null || params[k] === defaultEmbedParams[k]) {
|
||||
continue;
|
||||
}
|
||||
switch (typeof params[key]) {
|
||||
switch (typeof params[k]) {
|
||||
case 'number':
|
||||
normalizedParams[key] = params[key].toString();
|
||||
normalizedParams[k] = params[k].toString();
|
||||
break;
|
||||
case 'boolean':
|
||||
normalizedParams[key] = params[key] ? 'true' : 'false';
|
||||
normalizedParams[k] = params[k] ? 'true' : 'false';
|
||||
break;
|
||||
default:
|
||||
normalizedParams[key] = params[key];
|
||||
normalizedParams[k] = params[k];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export async function getUserEnvironment(): Promise<UserEnvironment> {
|
||||
}
|
||||
}
|
||||
|
||||
const browserData = uaData.fullVersionList.find((item) => !/^\s*not.+a.+brand\s*$/i.test(item.brand));
|
||||
const browserData = uaData.fullVersionList.find((item: any) => !/^\s*not.+a.+brand\s*$/i.test(item.brand));
|
||||
return {
|
||||
os: `${uaData.platform} ${osVersion}`,
|
||||
browser: browserData ? `${browserData.brand} v${browserData.version}` : 'Unknown',
|
||||
|
||||
@@ -21,7 +21,7 @@ export class SnowfallEffect {
|
||||
}>;
|
||||
private uniforms: Record<string, {
|
||||
type: string;
|
||||
value: number[] | Float32Array;
|
||||
value: number | number[] | Float32Array;
|
||||
location: WebGLUniformLocation;
|
||||
}>;
|
||||
private texture: WebGLTexture;
|
||||
@@ -44,9 +44,9 @@ export class SnowfallEffect {
|
||||
start: number;
|
||||
previous: number;
|
||||
} = {
|
||||
start: 0,
|
||||
previous: 0,
|
||||
};
|
||||
start: 0,
|
||||
previous: 0,
|
||||
};
|
||||
private raf = 0;
|
||||
|
||||
private density: number = 1 / 90;
|
||||
@@ -90,7 +90,7 @@ export class SnowfallEffect {
|
||||
mat2: 'uniformMatrix2fv',
|
||||
mat3: 'uniformMatrix3fv',
|
||||
mat4: 'uniformMatrix4fv',
|
||||
};
|
||||
} as const;
|
||||
|
||||
private CAMERA = {
|
||||
fov: 60,
|
||||
@@ -167,7 +167,7 @@ export class SnowfallEffect {
|
||||
return { ...this.WIND };
|
||||
}
|
||||
|
||||
private initShader(type, source): WebGLShader {
|
||||
private initShader(type: number, source: string): WebGLShader {
|
||||
const { gl } = this;
|
||||
const shader = gl.createShader(type);
|
||||
if (shader == null) throw new Error('Failed to create shader');
|
||||
@@ -224,7 +224,7 @@ export class SnowfallEffect {
|
||||
}
|
||||
}
|
||||
|
||||
private setBuffer(name: string, value?) {
|
||||
private setBuffer(name: string, value?: number[] | undefined) {
|
||||
const { gl, buffers } = this;
|
||||
const buffer = buffers[name];
|
||||
|
||||
@@ -253,18 +253,18 @@ export class SnowfallEffect {
|
||||
}
|
||||
}
|
||||
|
||||
private setUniform(name: string, value?) {
|
||||
private setUniform(name: string, value?: number | number[] | Float32Array<ArrayBufferLike> | undefined) {
|
||||
const { gl, uniforms } = this;
|
||||
const uniform = uniforms[name];
|
||||
const setter = this.UNIFORM_SETTERS[uniform.type];
|
||||
const setter = this.UNIFORM_SETTERS[uniform.type as keyof typeof this.UNIFORM_SETTERS];
|
||||
const isMatrix = /^mat[2-4]$/i.test(uniform.type);
|
||||
|
||||
uniform.value = value ?? uniform.value;
|
||||
|
||||
if (isMatrix) {
|
||||
gl[setter](uniform.location, false, uniform.value);
|
||||
(gl as any)[setter](uniform.location, false, uniform.value);
|
||||
} else {
|
||||
gl[setter](uniform.location, uniform.value);
|
||||
(gl as any)[setter](uniform.location, uniform.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user