Skip to content

Commit 0e8bad0

Browse files
committed
Fix 750
1 parent 20c8e12 commit 0e8bad0

File tree

10 files changed

+41
-33
lines changed

10 files changed

+41
-33
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ This driver uses semantic versioning:
1616

1717
## [unreleased]
1818

19+
### Fixed
20+
21+
- Changed all uses of `Record<string, unknown>` to `Record<string, any>` [#750](https://github.com/arangodb/arangojs/issues/750)
22+
23+
This should allow using more specific types without having to implement
24+
index signatures.
25+
1926
## [7.6.0] - 2021-10-20
2027

2128
### Added

src/aql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export type AqlValue =
8080
| boolean
8181
| null
8282
| undefined
83-
| Record<string, unknown>
83+
| Record<string, any>
8484
| any[];
8585

8686
/**

src/collection.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ export type CollectionImportResult = {
11301130
/**
11311131
* Result of retrieving edges in a collection.
11321132
*/
1133-
export type CollectionEdgesResult<T extends Record<string, unknown> = any> = {
1133+
export type CollectionEdgesResult<T extends Record<string, any> = any> = {
11341134
edges: Edge<T>[];
11351135
stats: {
11361136
scannedIndex: number;
@@ -1192,7 +1192,7 @@ export type SimpleQueryUpdateByExampleResult = {
11921192
* replaced with AQL queries.
11931193
*/
11941194
export type SimpleQueryRemoveByKeysResult<
1195-
T extends Record<string, unknown> = any
1195+
T extends Record<string, any> = any
11961196
> = {
11971197
/**
11981198
* Number of documents removed.
@@ -1230,7 +1230,7 @@ export type SimpleQueryRemoveByKeysResult<
12301230
* const documents = db.collection("persons") as DocumentCollection<Person>;
12311231
* ```
12321232
*/
1233-
export interface DocumentCollection<T extends Record<string, unknown> = any>
1233+
export interface DocumentCollection<T extends Record<string, any> = any>
12341234
extends ArangoCollection {
12351235
/**
12361236
* Checks whether the collection exists.
@@ -2585,7 +2585,7 @@ export interface DocumentCollection<T extends Record<string, unknown> = any>
25852585
* const edges = db.collection("friends") as EdgeCollection<Friend>;
25862586
* ```
25872587
*/
2588-
export interface EdgeCollection<T extends Record<string, unknown> = any>
2588+
export interface EdgeCollection<T extends Record<string, any> = any>
25892589
extends DocumentCollection<T> {
25902590
/**
25912591
* Retrieves the document matching the given key or id.
@@ -3320,7 +3320,7 @@ export interface EdgeCollection<T extends Record<string, unknown> = any>
33203320
* @internal
33213321
* @hidden
33223322
*/
3323-
export class Collection<T extends Record<string, unknown> = any>
3323+
export class Collection<T extends Record<string, any> = any>
33243324
implements EdgeCollection<T>, DocumentCollection<T> {
33253325
//#region attributes
33263326
protected _name: string;
@@ -3337,14 +3337,14 @@ export class Collection<T extends Record<string, unknown> = any>
33373337
}
33383338

33393339
//#region internals
3340-
protected _get<T extends Record<string, unknown>>(path: string, qs?: any) {
3340+
protected _get<T extends Record<string, any>>(path: string, qs?: any) {
33413341
return this._db.request(
33423342
{ path: `/_api/collection/${this._name}/${path}`, qs },
33433343
(res) => res.body as ArangoResponseMetadata & T
33443344
);
33453345
}
33463346

3347-
protected _put<T extends Record<string, unknown>>(path: string, body?: any) {
3347+
protected _put<T extends Record<string, any>>(path: string, body?: any) {
33483348
return this._db.request(
33493349
{
33503350
method: "PUT",

src/database.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ export type CreateUserOptions = {
13521352
*
13531353
* Default: `{}`
13541354
*/
1355-
extra?: Record<string, unknown>;
1355+
extra?: Record<string, any>;
13561356
};
13571357

13581358
/**
@@ -1374,7 +1374,7 @@ export type UserOptions = {
13741374
*
13751375
* Default: `{}`
13761376
*/
1377-
extra?: Record<string, unknown>;
1377+
extra?: Record<string, any>;
13781378
};
13791379

13801380
/**
@@ -2029,7 +2029,7 @@ export class Database {
20292029
* const edges = db.collection("friends") as EdgeCollection<Friend>;
20302030
* ```
20312031
*/
2032-
collection<T extends Record<string, unknown> = any>(
2032+
collection<T extends Record<string, any> = any>(
20332033
collectionName: string
20342034
): DocumentCollection<T> & EdgeCollection<T> {
20352035
if (!this._collections.has(collectionName)) {
@@ -2064,7 +2064,7 @@ export class Database {
20642064
* const documents = db.createCollection<Person>("persons");
20652065
* ```
20662066
*/
2067-
async createCollection<T extends Record<string, unknown> = any>(
2067+
async createCollection<T extends Record<string, any> = any>(
20682068
collectionName: string,
20692069
options?: CreateCollectionOptions & {
20702070
type?: CollectionType.DOCUMENT_COLLECTION;
@@ -2099,13 +2099,13 @@ export class Database {
20992099
* });
21002100
* ```
21012101
*/
2102-
async createCollection<T extends Record<string, unknown> = any>(
2102+
async createCollection<T extends Record<string, any> = any>(
21032103
collectionName: string,
21042104
options: CreateCollectionOptions & {
21052105
type: CollectionType.EDGE_COLLECTION;
21062106
}
21072107
): Promise<EdgeCollection<T>>;
2108-
async createCollection<T extends Record<string, unknown> = any>(
2108+
async createCollection<T extends Record<string, any> = any>(
21092109
collectionName: string,
21102110
options?: CreateCollectionOptions & { type?: CollectionType }
21112111
): Promise<DocumentCollection<T> & EdgeCollection<T>> {
@@ -2142,7 +2142,7 @@ export class Database {
21422142
* const edges = db.createEdgeCollection<Friend>("friends");
21432143
* ```
21442144
*/
2145-
async createEdgeCollection<T extends Record<string, unknown> = any>(
2145+
async createEdgeCollection<T extends Record<string, any> = any>(
21462146
collectionName: string,
21472147
options?: CreateCollectionOptions
21482148
): Promise<EdgeCollection<T>> {

src/documents.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,28 @@ export type EdgeMetadata = {
4545
/**
4646
* Type representing an object that can be stored in a collection.
4747
*/
48-
export type DocumentData<T extends Record<string, unknown> = any> = T &
48+
export type DocumentData<T extends Record<string, any> = any> = T &
4949
Partial<DocumentMetadata> &
5050
Partial<EdgeMetadata>;
5151

5252
/**
5353
* Type representing an object that can be stored in an edge collection.
5454
*/
55-
export type EdgeData<T extends Record<string, unknown> = any> = T &
55+
export type EdgeData<T extends Record<string, any> = any> = T &
5656
Partial<DocumentMetadata> &
5757
EdgeMetadata;
5858

5959
/**
6060
* Type representing a document stored in a collection.
6161
*/
62-
export type Document<T extends Record<string, unknown> = any> = T &
62+
export type Document<T extends Record<string, any> = any> = T &
6363
DocumentMetadata &
6464
Partial<EdgeMetadata>;
6565

6666
/**
6767
* Type representing an edge document stored in an edge collection.
6868
*/
69-
export type Edge<T extends Record<string, unknown> = any> = T &
69+
export type Edge<T extends Record<string, any> = any> = T &
7070
DocumentMetadata &
7171
EdgeMetadata;
7272

@@ -77,7 +77,7 @@ export type Edge<T extends Record<string, unknown> = any> = T &
7777
* This differs from `Partial` in that it also applies itself to any nested
7878
* objects recursively.
7979
*/
80-
export type Patch<T = Record<string, unknown>> = {
80+
export type Patch<T = Record<string, any>> = {
8181
[K in keyof T]?: T[K] | Patch<T[K]>;
8282
};
8383

src/graph.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ export type GraphCreateOptions = {
380380
*
381381
* @param T - Type to use for document data. Defaults to `any`.
382382
*/
383-
export class GraphVertexCollection<T extends Record<string, unknown> = any>
383+
export class GraphVertexCollection<T extends Record<string, any> = any>
384384
implements ArangoCollection {
385385
protected _db: Database;
386386
protected _name: string;
@@ -787,7 +787,7 @@ export class GraphVertexCollection<T extends Record<string, unknown> = any>
787787
*
788788
* @param T - Type to use for document data. Defaults to `any`.
789789
*/
790-
export class GraphEdgeCollection<T extends Record<string, unknown> = any>
790+
export class GraphEdgeCollection<T extends Record<string, any> = any>
791791
implements ArangoCollection {
792792
protected _db: Database;
793793
protected _name: string;
@@ -1347,7 +1347,7 @@ export class Graph {
13471347
* @param T - Type to use for document data. Defaults to `any`.
13481348
* @param collection - Name of the vertex collection.
13491349
*/
1350-
vertexCollection<T extends Record<string, unknown> = any>(
1350+
vertexCollection<T extends Record<string, any> = any>(
13511351
collection: string | ArangoCollection
13521352
): GraphVertexCollection<T> {
13531353
if (isArangoCollection(collection)) {
@@ -1510,7 +1510,7 @@ export class Graph {
15101510
* const edgeCollection = graphEdgeCollection.collection;
15111511
* ```
15121512
*/
1513-
edgeCollection<T extends Record<string, unknown> = any>(
1513+
edgeCollection<T extends Record<string, any> = any>(
15141514
collection: string | ArangoCollection
15151515
): GraphEdgeCollection<T> {
15161516
if (isArangoCollection(collection)) {

src/test/14-document-collections.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ describe("DocumentCollection API", function () {
5656
const data = { foo: "bar" };
5757
let meta: DocumentMetadata[];
5858
beforeEach(async () => {
59-
meta = await Promise.all([
60-
collection.save(data),
61-
collection.save(data),
62-
collection.save(data),
63-
]);
59+
const c = collection as DocumentCollection<{ foo: string }>;
60+
meta = await Promise.all([c.save(data), c.save(data), c.save(data)]);
6461
});
6562
it("returns multiple documents in the collection", async () => {
6663
const docs = await collection.documents(meta);

src/test/15-edge-collections.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ describe("EdgeCollection API", function () {
176176
});
177177
});
178178
describe("edgeCollection.traversal", () => {
179-
let knows: EdgeCollection<Record<string, unknown>>;
179+
let knows: EdgeCollection<Record<string, any>>;
180180
beforeEach(async () => {
181181
let person;
182182
[knows, person] = await Promise.all<

src/view.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ export type ArangoSearchViewPropertiesOptions = {
332332
* ArangoSearch View.
333333
*/
334334
export class View<
335-
PropertiesOptions extends Record<string, unknown> = any,
336-
Properties extends Record<string, unknown> = any
335+
PropertiesOptions extends Record<string, any> = any,
336+
Properties extends Record<string, any> = any
337337
> {
338338
protected _name: string;
339339
protected _db: Database;

tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
"strict": true,
2525
"strictFunctionTypes": true,
2626
"strictNullChecks": true,
27-
"target": "es2016"
27+
"target": "es2016",
28+
"emitDecoratorMetadata": true,
29+
"experimentalDecorators": true,
30+
"declarationMap": true,
31+
"resolveJsonModule": true
2832
},
2933
"exclude": ["node_modules", "build"]
3034
}

0 commit comments

Comments
 (0)