【问题标题】:Failed to compile the ionic project无法编译离子项目
【发布时间】:2020-08-04 04:03:03
【问题描述】:

错误:此模块使用'export ='声明,只能使用 使用“allowSyntheticDefaultImports”时默认导入 旗帜。 文件错误:

1 从“表单数据”导入表单数据; ~~~~~~~~

node_modules/@kintone/rest-api-client/node_modules/form-data/index.d.ts:10:1

10 导出=表单数据; ~~~~~~~~~~~~~~~~~~~~

这是文件的代码:

// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
//                 Leon Yu <https://github.com/leonyu>
//                 BendingBender <https://github.com/BendingBender>
//                 Maple Miao <https://github.com/mapleeit>

/// <reference types="node" />
import * as stream from 'stream';
import * as http from 'http';

export= FormData;

// Extracted because @types/node doesn't export interfaces.
interface ReadableOptions {
highWaterMark?: number;
encoding?: string;
objectMode?: boolean;
read?(this: stream.Readable, size: number): void;
destroy?(this: stream.Readable, error: Error | null, callback: (error: Error | null) => 
void): void;
autoDestroy?: boolean;
}

interface Options extends ReadableOptions {
writable?: boolean;
readable?: boolean;
dataSize?: number;
maxDataSize?: number;
pauseStreams?: boolean;
}

declare class FormData extends stream.Readable {
constructor(options?: Options);
append(key: string, value: any, options?: FormData.AppendOptions | string): void;
getHeaders(userHeaders?: FormData.Headers): FormData.Headers;
submit(
  params: string | FormData.SubmitOptions,
  callback?: (error: Error | null, response: http.IncomingMessage) => void
): http.ClientRequest;
getBuffer(): Buffer;
getBoundary(): string;
getLength(callback: (err: Error | null, length: number) => void): void;
getLengthSync(): number;
hasKnownLength(): boolean;
}

declare namespace FormData {
interface Headers {
  [key: string]: any;
}

interface AppendOptions {
  header?: string | Headers;
  knownLength?: number;
  filename?: string;
  filepath?: string;
  contentType?: string;
}

interface SubmitOptions extends http.RequestOptions {
  protocol?: 'https:' | 'http:';
}

}

【问题讨论】:

    标签: javascript angular typescript ionic-framework


    【解决方案1】:

    请尝试将allowSyntheticDefaultImports: true 添加到tsconfig,看看是否能解决问题。

    这是一个类似查询的链接: This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag

    此外,以下是一些编译器选项: https://www.typescriptlang.org/docs/handbook/compiler-options.html

    希望这会有所帮助。

    【讨论】:

      【解决方案2】:

      您应该将 allowSyntheticDefaultImports 设置为 false 而不是 true

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-11-08
        • 2020-04-01
        • 2022-01-15
        • 2020-12-04
        • 2013-12-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多