mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-04 07:52:51 +00:00
fix: stub out the Context class (#41961)
* fix: stub out the Context class * fix: _context is actually an array * fix: single term = single context
This commit is contained in:
parent
4e24fd4188
commit
bcfad61323
@ -1,4 +1,4 @@
|
||||
import { Term, NamedNode, Dataset, Literal, DatasetCore, BlankNode } from 'rdf-js';
|
||||
import { Term, NamedNode, Dataset, Literal, DatasetCore, BlankNode, Quad_Graph } from 'rdf-js';
|
||||
import Clownface = require('clownface/lib/Clownface');
|
||||
import clownface = require('clownface');
|
||||
|
||||
@ -204,3 +204,8 @@ let multipleLiterals: clownface.SafeClownface<Dataset, Literal> = safeCf.literal
|
||||
multipleLiterals = clownface({ dataset }).node([ 'a', 10, false ]);
|
||||
|
||||
const multipleMixedTerms: clownface.SafeClownface<Dataset> = clownface({ dataset }).node([ 'a', node, null ]);
|
||||
|
||||
// .context
|
||||
const ctxTerm: Literal = fromSingleArrayLiteral._context[0].term;
|
||||
const ctxGraph: Quad_Graph | undefined = fromSingleArrayLiteral._context[0].graph;
|
||||
const ctxDataset: Dataset = fromSingleArrayLiteral._context[0].dataset;
|
||||
|
||||
4
types/clownface/index.d.ts
vendored
4
types/clownface/index.d.ts
vendored
@ -5,6 +5,7 @@
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Term, DatasetCore, Quad_Graph, NamedNode, BlankNode, Literal } from 'rdf-js';
|
||||
import { Context } from './lib/Context';
|
||||
|
||||
declare namespace clownface {
|
||||
type TermOrClownface = Clownface | Term;
|
||||
@ -49,7 +50,7 @@ declare namespace clownface {
|
||||
readonly values: string[];
|
||||
readonly dataset: D;
|
||||
readonly datasets: D[];
|
||||
readonly _context: any;
|
||||
readonly _context: Array<Context<D, T>>;
|
||||
list(): Iterable<SingleContextClownface<D>>;
|
||||
toArray(): Array<Clownface<D, T>>;
|
||||
filter(cb: (quad: Clownface<D, T>) => boolean): Clownface<D, T>;
|
||||
@ -108,6 +109,7 @@ declare namespace clownface {
|
||||
readonly terms: [T];
|
||||
readonly value: string;
|
||||
readonly values: [string];
|
||||
readonly _context: [Context<D, T>];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
3
types/clownface/lib/Clownface.d.ts
vendored
3
types/clownface/lib/Clownface.d.ts
vendored
@ -15,6 +15,7 @@ import {
|
||||
SingleContextClownface,
|
||||
SingleOrOneElementArray
|
||||
} from '..';
|
||||
import { Context } from './Context';
|
||||
|
||||
declare class Clownface<D extends DatasetCore = DatasetCore, T extends Term = Term> implements ClownfaceContract<D, T> {
|
||||
constructor(options: ClownfaceInit & Partial<WithSingleTerm<T> | WithTerms<T>> & Partial<WithSingleValue | WithValues>);
|
||||
@ -24,7 +25,7 @@ declare class Clownface<D extends DatasetCore = DatasetCore, T extends Term = Te
|
||||
readonly values: string[];
|
||||
readonly dataset: D;
|
||||
readonly datasets: D[];
|
||||
readonly _context: any;
|
||||
readonly _context: Array<Context<D, T>>;
|
||||
list(): Iterable<SingleContextClownface<D>>;
|
||||
toArray(): Array<Clownface<D, T>>;
|
||||
filter(cb: (quad: Clownface<D, T>) => boolean): Clownface<D, T>;
|
||||
|
||||
18
types/clownface/lib/Context.d.ts
vendored
Normal file
18
types/clownface/lib/Context.d.ts
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
import { DatasetCore, Quad_Graph, Term } from 'rdf-js';
|
||||
|
||||
declare namespace Context {
|
||||
interface Context<D extends DatasetCore, T extends Term> {
|
||||
dataset: D;
|
||||
graph?: Quad_Graph;
|
||||
term: T;
|
||||
}
|
||||
}
|
||||
|
||||
declare class Context<D extends DatasetCore, T extends Term> implements Context.Context<D, T> {
|
||||
constructor(dataset: D, graph: Quad_Graph | undefined, value: any);
|
||||
dataset: D;
|
||||
graph?: Quad_Graph;
|
||||
term: T;
|
||||
}
|
||||
|
||||
export = Context;
|
||||
Loading…
Reference in New Issue
Block a user