fix: 导入 file-type 时出错

https://github.com/microsoft/TypeScript/issues/43329
This commit is contained in:
Clansty 2022-02-26 00:33:12 +08:00
parent 081ecde6b7
commit 61c79bb0e7
No known key found for this signature in database
GPG Key ID: 05F8479BA63A8E92
2 changed files with 2 additions and 2 deletions

View File

@ -8,7 +8,7 @@ const log = getLogger('ForwardHelper');
export default {
async downloadToCustomFile(url: string) {
const { fileTypeFromBuffer } = await import('file-type');
const { fileTypeFromBuffer } = await (Function('return import("file-type")')() as Promise<typeof import('file-type')>);
const file = await fetchFile(url);
const type = await fileTypeFromBuffer(file);
return new CustomFile(`image.${type.ext}`, file.length, '', file);

View File

@ -1,6 +1,6 @@
{
"compilerOptions": {
"module": "CommonJS",
"module": "nodenext",
"target": "ESNext",
"esModuleInterop": true,
"sourceMap": false,