mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
fix: rdf-js parsers actually return a quad stream (#41298)
* fix: rdf-js parsers actually return a quad stream * test: verify parser satisfies generic param
This commit is contained in:
parent
fff3323ed9
commit
98f5d66f4f
7
types/rdfjs__parser-jsonld/index.d.ts
vendored
7
types/rdfjs__parser-jsonld/index.d.ts
vendored
@ -3,9 +3,8 @@
|
||||
// Definitions by: Chris Wilkinson <https://github.com/thewilkybarkid>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { EventEmitter } from 'events';
|
||||
import { Context } from 'jsonld/jsonld-spec';
|
||||
import { DataFactory, Sink, Stream } from 'rdf-js';
|
||||
import { DataFactory, Sink, Stream, BaseQuad, Quad } from 'rdf-js';
|
||||
|
||||
declare namespace Parser {
|
||||
interface ParserOptions {
|
||||
@ -15,10 +14,10 @@ declare namespace Parser {
|
||||
}
|
||||
}
|
||||
|
||||
declare class Parser implements Sink {
|
||||
declare class Parser<Q extends BaseQuad = Quad> implements Sink<Q> {
|
||||
constructor(options?: Parser.ParserOptions);
|
||||
|
||||
import(stream: Stream, options?: Parser.ParserOptions): EventEmitter;
|
||||
import(stream: Stream<Q>, options?: Parser.ParserOptions): Stream<Q>;
|
||||
}
|
||||
|
||||
export = Parser;
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import Parser = require('@rdfjs/parser-jsonld');
|
||||
import { EventEmitter } from 'events';
|
||||
import { Context } from 'jsonld/jsonld-spec';
|
||||
import { DataFactory, Sink, Stream } from 'rdf-js';
|
||||
import { DataFactory, Sink, Stream, BaseQuad } from 'rdf-js';
|
||||
|
||||
const baseIRI = '';
|
||||
const context: Context = {} as any;
|
||||
@ -14,6 +13,15 @@ const parser3 = new Parser({ baseIRI, context, factory });
|
||||
|
||||
const sink: Sink = parser1;
|
||||
|
||||
const eventEmitter1: EventEmitter = parser1.import(stream);
|
||||
const eventEmitter2: EventEmitter = parser1.import(stream, {});
|
||||
const eventEmitter3: EventEmitter = parser1.import(stream, { baseIRI, context, factory });
|
||||
const eventEmitter1: Stream = parser1.import(stream);
|
||||
const eventEmitter2: Stream = parser1.import(stream, {});
|
||||
const eventEmitter3: Stream = parser1.import(stream, { baseIRI, context, factory });
|
||||
|
||||
interface SpecializedQuad extends BaseQuad {
|
||||
foo: string;
|
||||
}
|
||||
const typedStream: Stream<SpecializedQuad> = <any> {};
|
||||
const typedParser: Parser<SpecializedQuad> = <any> {};
|
||||
const typedImported: Stream<SpecializedQuad> = typedParser.import(typedStream);
|
||||
const typedImported1: Stream<SpecializedQuad> = typedParser.import(typedStream, {});
|
||||
const typedImported2: Stream<SpecializedQuad> = typedParser.import(typedStream, { baseIRI, context, factory });
|
||||
|
||||
7
types/rdfjs__parser-n3/index.d.ts
vendored
7
types/rdfjs__parser-n3/index.d.ts
vendored
@ -3,18 +3,17 @@
|
||||
// Definitions by: tpluscode <https://github.com/tpluscode>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { EventEmitter } from 'events';
|
||||
import { Sink, Stream, DataFactory } from 'rdf-js';
|
||||
import { Sink, Stream, DataFactory, BaseQuad, Quad } from 'rdf-js';
|
||||
|
||||
interface ParserOptions {
|
||||
baseIRI?: string;
|
||||
factory?: DataFactory;
|
||||
}
|
||||
|
||||
declare class Parser implements Sink {
|
||||
declare class Parser<Q extends BaseQuad = Quad> implements Sink<Q> {
|
||||
constructor(options?: ParserOptions);
|
||||
|
||||
import(stream: Stream, options?: ParserOptions): EventEmitter;
|
||||
import(stream: Stream<Q>, options?: ParserOptions): Stream<Q>;
|
||||
}
|
||||
|
||||
export = Parser;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import ParserN3 = require('@rdfjs/parser-n3');
|
||||
import { Stream, DataFactory, Sink } from 'rdf-js';
|
||||
import { EventEmitter } from 'events';
|
||||
import { Stream, DataFactory, Sink, BaseQuad } from 'rdf-js';
|
||||
|
||||
const factory: DataFactory = <any> {};
|
||||
const baseIRI = '';
|
||||
@ -13,7 +12,16 @@ const parser3 = new ParserN3({ baseIRI });
|
||||
const sink: Sink = parser;
|
||||
|
||||
const input: Stream = <any> {};
|
||||
const output: EventEmitter = parser.import(input);
|
||||
const output1: EventEmitter = parser.import(input, {});
|
||||
const output2: EventEmitter = parser.import(input, { factory });
|
||||
const output3: EventEmitter = parser.import(input, { baseIRI });
|
||||
const output: Stream = parser.import(input);
|
||||
const output1: Stream = parser.import(input, {});
|
||||
const output2: Stream = parser.import(input, { factory });
|
||||
const output3: Stream = parser.import(input, { baseIRI });
|
||||
|
||||
interface SpecializedQuad extends BaseQuad {
|
||||
foo: string;
|
||||
}
|
||||
const typedStream: Stream<SpecializedQuad> = <any> {};
|
||||
const typedParser: ParserN3<SpecializedQuad> = <any> {};
|
||||
const typedImported: Stream<SpecializedQuad> = typedParser.import(typedStream);
|
||||
const typedImported1: Stream<SpecializedQuad> = typedParser.import(typedStream, {});
|
||||
const typedImported2: Stream<SpecializedQuad> = typedParser.import(typedStream, { baseIRI, factory });
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
import { EventEmitter } from 'events';
|
||||
import { Context } from 'jsonld/jsonld-spec';
|
||||
import { Sink, Stream } from 'rdf-js';
|
||||
import { Sink, Stream, BaseQuad, Quad } from 'rdf-js';
|
||||
|
||||
declare namespace Serializer {
|
||||
interface SerializerOptions {
|
||||
@ -19,10 +19,10 @@ declare namespace Serializer {
|
||||
}
|
||||
}
|
||||
|
||||
declare class Serializer implements Sink {
|
||||
declare class Serializer<Q extends BaseQuad = Quad> implements Sink<Q> {
|
||||
constructor(options?: Serializer.SerializerOptions);
|
||||
|
||||
import(stream: Stream, options?: Serializer.SerializerOptions): EventEmitter;
|
||||
import(stream: Stream<Q>, options?: Serializer.SerializerOptions): EventEmitter;
|
||||
}
|
||||
|
||||
export = Serializer;
|
||||
|
||||
6
types/rdfjs__serializer-jsonld/index.d.ts
vendored
6
types/rdfjs__serializer-jsonld/index.d.ts
vendored
@ -4,7 +4,7 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { EventEmitter } from 'events';
|
||||
import { Sink, Stream } from 'rdf-js';
|
||||
import { Sink, Stream, BaseQuad, Quad } from 'rdf-js';
|
||||
|
||||
declare namespace Serializer {
|
||||
interface SerializerOptions {
|
||||
@ -12,10 +12,10 @@ declare namespace Serializer {
|
||||
}
|
||||
}
|
||||
|
||||
declare class Serializer implements Sink {
|
||||
declare class Serializer<Q extends BaseQuad = Quad> implements Sink<Q> {
|
||||
constructor(options?: Serializer.SerializerOptions);
|
||||
|
||||
import(stream: Stream, options?: Serializer.SerializerOptions): EventEmitter;
|
||||
import(stream: Stream<Q>, options?: Serializer.SerializerOptions): EventEmitter;
|
||||
}
|
||||
|
||||
export = Serializer;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user