簡體   English   中英

Typescript papaparse 沒有過載匹配這個調用

[英]Typescript papaparse No overload matches this call

我在 typescript 中使用Papaparse庫。

import Papa from 'papaparse';

Papa.parse(filePath, {
  download: true, 
  header: true,
  dynamicTyping: true,
  skipEmptyLines: true,
};

filepath類型是string

我在文件路徑上收到錯誤:

No overload matches this call. The last overload generated the following error. The 'string' type argument is not assignable to the 'unique symbol' type parameter.

@types/papaparse中,有


/**
 * Parse local files
 * @param file a File object obtained from the DOM.
 * @param config a config object which contains a callback.
 * @returns Doesn't return anything. Results are provided asynchronously to a callback function.
 */
// tslint:disable-next-line: no-unnecessary-generics
export function parse<T, TFile extends LocalFile = LocalFile>(file: TFile, config: ParseLocalConfig<T, TFile>): void;

/**
 * Parse remote files
 * @param url the path or URL to the file to download.
 * @param config a config object.
 * @returns Doesn't return anything. Results are provided asynchronously to a callback function.
 */
// tslint:disable-next-line: no-unnecessary-generics
export function parse<T>(url: string, config: ParseRemoteConfig<T>): void;

我添加了complete的 function 並像這樣更新了我的代碼:

import { parse, ParseResult } from 'papaparse';

parse(filePath, {
  download: true, 
  header: true,
  dynamicTyping: true,
  skipEmptyLines: true,
  complete: function (results: ParseResult<Record<string, unknown>>) {
    /* ...code stuff... */
  }
};

它有效。 謝謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM