mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
adjust return types from safe clownface (#41296)
* adjust return types from safe clownface * style: tslint fixes
This commit is contained in:
committed by
Ryan Cavanaugh
parent
7bd6f85442
commit
f85a085e48
@@ -1,4 +1,4 @@
|
||||
import { Term, NamedNode, Dataset, Literal } from 'rdf-js';
|
||||
import { Term, NamedNode, Dataset, Literal, DatasetCore, BlankNode } from 'rdf-js';
|
||||
import Clownface = require('clownface/lib/Clownface');
|
||||
import clownface = require('clownface');
|
||||
|
||||
@@ -143,3 +143,18 @@ if (cf.value) {
|
||||
|
||||
// .values
|
||||
const values: string[] = cf.values;
|
||||
|
||||
const safeCf: clownface.SafeClownface = <any> {};
|
||||
|
||||
const singleBlankAuto: clownface.SingleContextClownface<DatasetCore, BlankNode> = safeCf.blankNode();
|
||||
const SingleBlank: clownface.SingleContextClownface<DatasetCore, BlankNode> = safeCf.blankNode('blank');
|
||||
const singleNamed: clownface.SingleContextClownface<DatasetCore, NamedNode> = safeCf.namedNode('http://example.com/a');
|
||||
const singleLiteral: clownface.SingleContextClownface<DatasetCore, Literal> = safeCf.literal('a');
|
||||
|
||||
const fromSingleArrayBLank: clownface.SingleContextClownface<DatasetCore, BlankNode> = safeCf.blankNode([ 'b1' ]);
|
||||
const fromSingleArrayNamed: clownface.SingleContextClownface<DatasetCore, NamedNode> = safeCf.namedNode([ 'http://example.com/a' ]);
|
||||
const fromSingleArrayLiteral: clownface.SingleContextClownface<DatasetCore, Literal> = safeCf.literal([ 'a' ]);
|
||||
|
||||
const multipleBlanks: clownface.SafeClownface<DatasetCore, BlankNode> = safeCf.blankNode([ 'b1', 'b2' ]);
|
||||
const multipleNamed: clownface.SafeClownface<DatasetCore, NamedNode> = safeCf.namedNode([ 'http://example.com/a', 'http://example.com/b' ]);
|
||||
const multipleLiterals: clownface.SafeClownface<DatasetCore, Literal> = safeCf.literal([ 'a', 'b' ]);
|
||||
|
||||
Vendored
+15
@@ -12,6 +12,7 @@ declare namespace clownface {
|
||||
|
||||
type AddCallback<D extends DatasetCore, X extends Term> = (added: SingleContextClownface<D, X>) => void;
|
||||
type SingleOrArray<T> = T | T[];
|
||||
type SingleOrOneElementArray<T> = T | [T];
|
||||
|
||||
type SingleOrArrayOfTerms = SingleOrArray<TermOrClownface>;
|
||||
type SingleOrArrayOfTermsOrLiterals = SingleOrArray<TermOrLiteral>;
|
||||
@@ -73,6 +74,20 @@ declare namespace clownface {
|
||||
}
|
||||
|
||||
interface SafeClownface<D extends DatasetCore = DatasetCore, T extends Term = Term> extends Clownface<D, T> {
|
||||
// tslint:disable:no-unnecessary-generics
|
||||
node<X extends Term = Term>(value: SingleOrOneElementArray<boolean | string | number | Term | null>, options?: NodeOptions): SingleContextClownface<D, X>;
|
||||
node<X extends Term = Term>(values: Array<boolean | string | number | Term | null>, options?: NodeOptions): SafeClownface<D, X>;
|
||||
// tslint:enable:no-unnecessary-generics
|
||||
|
||||
blankNode(value?: SingleOrOneElementArray<string>): SingleContextClownface<D, BlankNode>;
|
||||
blankNode(values: string[]): SafeClownface<D, BlankNode>;
|
||||
|
||||
literal(value: SingleOrOneElementArray<boolean | string | number | Term | null>, languageOrDatatype?: string | NamedNode): SingleContextClownface<D, Literal>;
|
||||
literal(values: Array<boolean | string | number | Term | null>, languageOrDatatype?: string | NamedNode): SafeClownface<D, Literal>;
|
||||
|
||||
namedNode(value: SingleOrOneElementArray<string | NamedNode>): SingleContextClownface<D, NamedNode>;
|
||||
namedNode(values: Array<string | NamedNode>): SafeClownface<D, NamedNode>;
|
||||
|
||||
filter(cb: (quad: SingleContextClownface<D, T>) => boolean): SafeClownface<D, T>;
|
||||
forEach(cb: (quad: SingleContextClownface<D, T>) => void): void;
|
||||
map<X>(cb: (quad: SingleContextClownface<D, T>, index: number) => X): X[];
|
||||
|
||||
Reference in New Issue
Block a user