Skip to content

Commit a9bf23a

Browse files
thewilkybarkidandrewbranch
authored andcommitted
Add @rdfjs/namespace (DefinitelyTyped#41082)
* Add @rdfjs/namespace * Add paths * Fix path * Fix linting * Extra test case * Add header * So the path *was* correct, it was the missing header...
1 parent 9456c19 commit a9bf23a

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

Diff for: types/rdfjs__namespace/index.d.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Type definitions for @rdfjs/namespace 1.1
2+
// Project: https://github.com/rdfjs-base/namespace
3+
// Definitions by: Chris Wilkinson <https://github.com/thewilkybarkid>
4+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5+
6+
import { DataFactory, NamedNode } from 'rdf-js';
7+
8+
declare function namespace(baseIRI: string, options?: namespace.BuilderOptions): namespace.NamespaceBuilder;
9+
10+
declare namespace namespace {
11+
interface NamespaceBuilder {
12+
(property: TemplateStringsArray | string): NamedNode;
13+
14+
readonly [property: string]: NamedNode;
15+
}
16+
17+
interface BuilderOptions {
18+
factory?: DataFactory;
19+
}
20+
}
21+
22+
export = namespace;

Diff for: types/rdfjs__namespace/rdfjs__namespace-tests.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import namespace = require('@rdfjs/namespace');
2+
import { NamespaceBuilder } from '@rdfjs/namespace';
3+
import { DataFactory, NamedNode } from 'rdf-js';
4+
5+
const factory: DataFactory = {} as any;
6+
7+
const builder1: NamespaceBuilder = namespace('http://schema.org/');
8+
const builder2: NamespaceBuilder = namespace('http://schema.org/', {});
9+
const builder3: NamespaceBuilder = namespace('http://schema.org/', { factory });
10+
11+
const node1: NamedNode = builder1.Thing;
12+
const node2: NamedNode = builder1.url;
13+
const node3: NamedNode = builder1('Thing');
14+
const node4: NamedNode = builder1('url');
15+
const node5: NamedNode = builder1`'Thing'`;
16+
const node6: NamedNode = builder1`url`;

Diff for: types/rdfjs__namespace/tsconfig.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"lib": [
5+
"es6"
6+
],
7+
"noImplicitAny": true,
8+
"noImplicitThis": true,
9+
"strictFunctionTypes": true,
10+
"strictNullChecks": true,
11+
"baseUrl": "../",
12+
"typeRoots": [
13+
"../"
14+
],
15+
"types": [],
16+
"noEmit": true,
17+
"forceConsistentCasingInFileNames": true,
18+
"paths": {
19+
"@rdfjs/namespace": [
20+
"rdfjs__namespace"
21+
]
22+
}
23+
},
24+
"files": [
25+
"index.d.ts",
26+
"rdfjs__namespace-tests.ts"
27+
]
28+
}

Diff for: types/rdfjs__namespace/tslint.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "extends": "dtslint/dt.json" }

0 commit comments

Comments
 (0)