admin管理员组文章数量:1417719
I use Papaparse lib in typescript.
import Papa from 'papaparse';
Papa.parse(filePath, {
download: true,
header: true,
dynamicTyping: true,
skipEmptyLines: true,
};
filepath
type is string
I get error on filePath:
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.
In @types/papaparse, there is
/**
* 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;
I use Papaparse lib in typescript.
import Papa from 'papaparse';
Papa.parse(filePath, {
download: true,
header: true,
dynamicTyping: true,
skipEmptyLines: true,
};
filepath
type is string
I get error on filePath:
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.
In @types/papaparse, there is
/**
* 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;
Share
Improve this question
edited Mar 11, 2022 at 8:09
Hasina Njaratin
asked Mar 11, 2022 at 6:53
Hasina NjaratinHasina Njaratin
4812 gold badges7 silver badges19 bronze badges
3
-
This import form...
import Papa from 'papaparse';
is used to importdefault
exports. Why don't you tryimport { parse } from 'papaparse';
and then use the function directly? – Nalin Ranjan Commented Mar 11, 2022 at 6:59 -
1
I have the impression that you are missing the function
plete(results: ParseResult<T>, file: TInput): void
from theconfig
argument. This may be confusing the piler to call a different overload than the one you think you are calling. – Nikos Paraskevopoulos Commented Mar 11, 2022 at 7:53 - i updated the body question. i still get errors – Hasina Njaratin Commented Mar 11, 2022 at 8:10
1 Answer
Reset to default 6I added plete
function and updated my code like this:
import { parse, ParseResult } from 'papaparse';
parse(filePath, {
download: true,
header: true,
dynamicTyping: true,
skipEmptyLines: true,
plete: function (results: ParseResult<Record<string, unknown>>) {
/* ...code stuff... */
}
};
and it works. thx
本文标签: javascriptTypescript papaparse No overload matches this callStack Overflow
版权声明:本文标题:javascript - Typescript papaparse No overload matches this call - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745267987a2650719.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论