所以我上了这门课
declare class Record<Entries extends Dict = Dict, Key extends keyof Entries = keyof Entries, FieldLookup extends Dict<keyof Entries, number> = Dict<keyof Entries, number>> {
keys: Key[];
length: number;
private readonly _fields;
private readonly _fieldLookup;
constructor(keys: Key[], fields: any[], fieldLookup?: FieldLookup);
forEach(visitor: Visitor<Entries, Key>): void;
map<Value>(visitor: MapVisitor<Value, Entries, Key>): Value[];
entries(): IterableIterator<[string, any]>;
values(): IterableIterator<Object>;
[Symbol.iterator](): IterableIterator<Object>;
toObject(): Entries;
get<K extends keyof Entries = keyof Entries>(key: K): Entries[K];
get(n: number): any;
has(key: Key | string | number): boolean;
}
它被用在这个函数中:
export function toObjects(
records: typeof neo4j.Record[],
converters: Converters
) {
const recordValues = records.map(record => {
const out: string[] = []
record.forEach((val: {}) => out.push(itemIntToString(val, converters)))
return out
})
return recordValues
}
即使forEach
方法似乎定义良好,我也会得到错误'Property 'forEach' does not exist on type 'typeof Record'
另外,值得注意的是,在使用typeof
的代码中有几个类似的错误
你知道它是从哪里来的吗?我很困惑。
编辑:neo4j这里是
declare const forExport: {
Record: typeof Record,
...
}
1条答案
按热度按时间z2acfund1#
在定义neo4j类型时,考虑删除Record之前的“typeof”。Typescript将类视为有效类型