strictNullChecks (#4666)
* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip
This commit is contained in:
parent
4ee40c3345
commit
987168b863
214 changed files with 939 additions and 785 deletions
|
@ -1,6 +1,6 @@
|
|||
type Acct = {
|
||||
username: string;
|
||||
host: string;
|
||||
host: string | null;
|
||||
};
|
||||
|
||||
export default Acct;
|
||||
|
|
|
@ -2,7 +2,7 @@ import config from '../config';
|
|||
import { toASCII } from 'punycode';
|
||||
import { URL } from 'url';
|
||||
|
||||
export function getFullApAccount(username: string, host: string) {
|
||||
export function getFullApAccount(username: string, host: string | null) {
|
||||
return host ? `${username}@${toPuny(host)}` : `${username}@${toPuny(config.host)}`;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,5 @@ export function extractDbHost(uri: string) {
|
|||
}
|
||||
|
||||
export function toPuny(host: string) {
|
||||
if (host == null) return null;
|
||||
return toASCII(host.toLowerCase());
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import fileType from 'file-type';
|
|||
import checkSvg from '../misc/check-svg';
|
||||
|
||||
export async function detectMine(path: string) {
|
||||
return new Promise<[string, string]>((res, rej) => {
|
||||
return new Promise<[string, string | null]>((res, rej) => {
|
||||
const readable = fs.createReadStream(path);
|
||||
readable
|
||||
.on('error', rej)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import * as fs from 'fs';
|
||||
import * as URL from 'url';
|
||||
import * as request from 'request';
|
||||
import config from '../config';
|
||||
import chalk from 'chalk';
|
||||
|
@ -26,7 +25,7 @@ export async function downloadUrl(url: string, path: string) {
|
|||
rej(error);
|
||||
});
|
||||
|
||||
const requestUrl = URL.parse(url).pathname.match(/[^\u0021-\u00ff]/) ? encodeURI(url) : url;
|
||||
const requestUrl = new URL(url).pathname.match(/[^\u0021-\u00ff]/) ? encodeURI(url) : url;
|
||||
|
||||
const req = request({
|
||||
url: requestUrl,
|
||||
|
|
|
@ -9,7 +9,6 @@ export default async function(): Promise<Meta> {
|
|||
} else {
|
||||
return Metas.save({
|
||||
id: genId(),
|
||||
hiddenTags: []
|
||||
} as Meta);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import fetchMeta from './fetch-meta';
|
||||
import { ILocalUser } from '../models/entities/user';
|
||||
import { Users } from '../models';
|
||||
import { ensure } from '../prelude/ensure';
|
||||
|
||||
export async function fetchProxyAccount(): Promise<ILocalUser> {
|
||||
const meta = await fetchMeta();
|
||||
return await Users.findOne({ username: meta.proxyAccount, host: null }) as ILocalUser;
|
||||
return await Users.findOne({ username: meta.proxyAccount!, host: null }).then(ensure) as ILocalUser;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ export class IdentifiableError extends Error {
|
|||
|
||||
constructor(id: string, message?: string) {
|
||||
super(message);
|
||||
this.message = message;
|
||||
this.message = message || '';
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ export function nyaize(text: string): string {
|
|||
// ja-JP
|
||||
.replace(/な/g, 'にゃ').replace(/ナ/g, 'ニャ').replace(/ナ/g, 'ニャ')
|
||||
// ko-KR
|
||||
.replace(/[나-낳]/g, (match: string) => String.fromCharCode(
|
||||
match.codePointAt(0) + '냐'.charCodeAt(0) - '나'.charCodeAt(0)
|
||||
.replace(/[나-낳]/g, match => String.fromCharCode(
|
||||
match.codePointAt(0)! + '냐'.charCodeAt(0) - '나'.charCodeAt(0)
|
||||
));
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ type MyType<T extends Schema> = {
|
|||
export type SchemaType<p extends Schema> =
|
||||
p['type'] extends 'number' ? number :
|
||||
p['type'] extends 'string' ? string :
|
||||
p['type'] extends 'array' ? MyType<p['items']>[] :
|
||||
p['type'] extends 'object' ? ObjType<p['properties']> :
|
||||
p['type'] extends 'array' ? MyType<NonNullable<p['items']>>[] :
|
||||
p['type'] extends 'object' ? ObjType<NonNullable<p['properties']>> :
|
||||
any;
|
||||
|
||||
export function convertOpenApiSchema(schema: Schema) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue