Skip to content

Commit dba4f84

Browse files
committedMay 6, 2021
Add Typescript definition
1 parent 6852699 commit dba4f84

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed
 
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 2.0
20+
21+
/**
22+
* Namespace element.
23+
*/
24+
type NamespaceElement = {
25+
/**
26+
* A unique identifier suitable for use within a shared context such as a REPL environment.
27+
*/
28+
alias: string;
29+
30+
/**
31+
* The package path from which the namespace element originates.
32+
*/
33+
path: string;
34+
35+
/**
36+
* The actual value included in the namespace.
37+
*/
38+
value: any;
39+
40+
/**
41+
* The value type (e.g., function, number, string, object, etc.).
42+
*/
43+
type: string;
44+
45+
/**
46+
* Related namespace elements, as identified by their package paths.
47+
*/
48+
related: string;
49+
};
50+
51+
/**
52+
* Returns the standard library namespace.
53+
*
54+
* @returns standard library namespace
55+
*/
56+
declare function namespace(): Array<NamespaceElement>;
57+
58+
59+
// EXPORTS //
60+
61+
export = namespace;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import namespace = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns an array of namespace objet...
25+
{
26+
namespace(); // $ExpectType NamespaceElement[]
27+
}
28+
29+
// The compiler throws an error if the function is provided arguments...
30+
{
31+
namespace( 3.12 ); // $ExpectError
32+
}

‎lib/node_modules/@stdlib/namespace/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"lib": "./lib",
2626
"test": "./test"
2727
},
28+
"types": "./docs/types",
2829
"scripts": {},
2930
"homepage": "https://github.com/stdlib-js/stdlib",
3031
"repository": {

0 commit comments

Comments
 (0)