diff --git a/README.md b/README.md
index bbf2a6f16e..746d9d9f3e 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,8 @@ Also see the [definitelytyped.org](http://definitelytyped.org) website, although
This section tracks the health of the repository and publishing process.
It may be helpful for contributors experiencing any issues with their PRs and packages.
-* All packages are type-checking/linting cleanly: [](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped)
-* All packages are being published to npm in under 10,000 seconds: [](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13)
+* All packages are [type-checking/linting](https://github.com/Microsoft/dtslint) cleanly: [](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped)
+* All packages are being [published to npm](https://github.com/Microsoft/types-publisher) in under an hour: [](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13)
* [typescript-bot](https://github.com/typescript-bot) has been active on DefinitelyTyped [](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14)
If anything here seems wrong, or any of the above are failing, please raise an issue in [the DefinitelyTyped Gitter channel](https://gitter.im/DefinitelyTyped/DefinitelyTyped).
@@ -229,7 +229,7 @@ It depends, but most pull requests will be merged within a week. PRs that have b
#### My PR is merged; when will the `@types` NPM package be updated?
-NPM packages should update within a few hours. If it's been more than 24 hours, ping @RyanCavanaugh and @andy-ms on the PR to investigate.
+NPM packages should update within a few minutes. If it's been more than an hour, mention the PR number on [the DefinitelyTyped Gitter channel](https://gitter.im/DefinitelyTyped/DefinitelyTyped) and the current maintainer will get the correct team member to investigate.
#### I'm writing a definition that depends on another definition. Should I use `` or an import?
@@ -327,14 +327,60 @@ If the standard is still a draft, it belongs here.
Use a name beginning with `dom-` and include a link to the standard as the "Project" link in the header.
When it graduates draft mode, we may remove it from DefinitelyTyped and deprecate the associated `@types` package.
-#### I want to update a package to a new major version
+#### How do DefinitelyTyped package versions relate to versions of the corresponding library?
-If you intend to continue updating the older version of the package, you may create a new subfolder with the current version e.g. `v2`, and copy existing files to it. If so, you will need to:
+_NOTE: The discussion in this section assumes familiarity with [Semantic versioning](https://semver.org/)_
+
+Each DefinitelyTyped package is versioned when published to NPM.
+The [types-publisher](https://github.com/Microsoft/types-publisher) (the tool that publishes `@types` packages to npm) will set the declaration package's version by using the `major.minor` version number listed in the first line of its `index.d.ts` file.
+For example, here are the first few lines of [Node's type declarations](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/1253faabf5e0d2c5470db6ea87795d7f96fef7e2/types/node/index.d.ts) for version `10.12.x` at the time of writing:
+
+```js
+// Type definitions for Node.js 10.12
+// Project: http://nodejs.org/
+// Definitions by: Microsoft TypeScript
+// DefinitelyTyped
+// Alberto Schiabel
+```
+
+Because `10.12` is at the end the first line, the npm version of the `@types/node` package will also be `10.12.x`.
+Note that the first-line comment in the `index.d.ts` file should only contain the `major.minor` version (e.g. `10.12`) and should not contain a patch version (e.g. `10.12.4`).
+This is because only the major and minor release numbers are aligned between library packages and type declaration packages.
+The patch release number of the type declaration package (e.g. `.0` in `10.12.0`) is initialized to zero by DefinitelyTyped and is incremented each time a new `@types/node` package is published to NPM for the same major/minor version of the corresponding library.
+
+Sometimes type declaration package versions and library package versions can get out of sync.
+Below are a few common reasons why, in order of how much they inconvenience users of a library.
+Only the last case is typically problematic.
+
+* As noted above, the patch version of the type declaration package is unrelated to the library patch version.
+ This allows DefinitelyTyped to safely update type declarations for the same major/minor version of a library.
+* If updating a package for new functionality, don't forget to update the version number to line up with that version of the library.
+ If users make sure versions correspond between JavaScript packages and their respective `@types` packages, then `npm update` should typically just work.
+* It's common for type declaration package updates to lag behind library updates because it's often library users, not maintainers, who update DefinitelyTyped when new library features are released.
+ So there may be a lag of days, weeks, or even months before a helpful community member sends a PR to update the type declaration package for a new library release.
+ If you're impacted by this, you can be the change you want to see in the world and you can be that helpful community member!
+
+:exclamation: If you're updating type declarations for a library, always set the `major.minor` version in the first line of `index.d.ts` to match the library version that you're documenting! :exclamation:
+
+#### If a library is updated to a new major version with breaking changes, how should I update its type declaration package?
+
+[Semantic versioning](https://semver.org/) requires that versions with breaking changes must increment the major version number.
+For example, a library that removes a publicly exported function after its `3.5.8` release must bump its version to `4.0.0` in its next release.
+Furthermore, when the library's `4.0.0` release is out, its DefinitelyTyped type declaration package should also be updated to `4.0.0`, including any breaking changes to the library's API.
+
+Many libraries have a large installed base of developers (including maintainers of other packages using that library as a dependency) who won't move right away to a new version that has breaking changes, because it might be months until a maintainer has time to rewrite code to adapt to the new version.
+In the meantime, users of old library versions still may want to update type declarations for older versions.
+
+If you intend to continue updating the older version of a library's type declarations, you may create a new subfolder (e.g. `/v2/`) named for the current (soon to be "old") version, and copy existing files from the current version to it.
+
+Because the root folder should always contain the type declarations for the latest ("new") version, you'll need to make a few changes to the files in your old-version subdirectory to ensure that relative path references point to the subdirectory, not the root.
1. Update the relative paths in `tsconfig.json` as well as `tslint.json`.
2. Add path mapping rules to ensure that tests are running against the intended version.
-For example [history v2 `tsconfig.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/history/v2/tsconfig.json) looks like:
+For example, the [`history`](https://github.com/ReactTraining/history/) library introduced breaking changes between version `2.x` and `3.x`.
+Because many users still consumed the older `2.x` version, a maintainer who wanted to update the type declarations for this library to `3.x` added a `v2` folder inside the history repository that contains type declarations for the older version.
+At the time of writing, the [history v2 `tsconfig.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/1253faabf5e0d2c5470db6ea87795d7f96fef7e2/types/history/v2/tsconfig.json) looks roughly like:
```json
{
@@ -352,10 +398,11 @@ For example [history v2 `tsconfig.json`](https://github.com/DefinitelyTyped/Defi
}
```
-If there are other packages on DefinitelyTyped that are incompatible with the new version, you will need to add path mappings to the old version. You will also need to do this for packages depending on packages depending on the old version.
+If there are other packages in DefinitelyTyped that are incompatible with the new version, you will need to add path mappings to the old version.
+You will also need to do this recursively for packages depending on packages depending on the old version.
-For example, `react-router` depends on `history@2`, so [react-router `tsconfig.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router/tsconfig.json) has a path mapping to `"history": [ "history/v2" ]`;
-transitively `react-router-bootstrap` (which depends on `react-router`) also adds a path mapping in its [tsconfig.json](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router-bootstrap/tsconfig.json).
+For example, `react-router` depends on `history@2`, so [react-router `tsconfig.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router/v2/tsconfig.json) has a path mapping to `"history": [ "history/v2" ]`.
+Transitively, `react-router-bootstrap` (which depends on `react-router`) also needed to add the same path mapping (`"history": [ "history/v2" ]`) in its `tsconfig.json` until its `react-router` dependency was updated to the latest version.
Also, `/// ` will not work with path mapping, so dependencies must use `import`.
diff --git a/notNeededPackages.json b/notNeededPackages.json
index 701978da24..f073197bf9 100644
--- a/notNeededPackages.json
+++ b/notNeededPackages.json
@@ -564,12 +564,24 @@
"sourceRepoURL": "https://www.npmjs.com/package/fast-simplex-noise",
"asOfVersion": "3.0.0"
},
+ {
+ "libraryName": "fastify-cors",
+ "typingsPackageName": "fastify-cors",
+ "sourceRepoURL": "https://github.com/fastify/fastify-cors",
+ "asOfVersion": "2.1.0"
+ },
{
"libraryName": "Fastify-JWT",
"typingsPackageName": "fastify-jwt",
"sourceRepoURL": "https://github.com/fastify/fastify-jwt",
"asOfVersion": "0.8.1"
},
+ {
+ "libraryName": "fastify-static",
+ "typingsPackageName": "fastify-static",
+ "sourceRepoURL": "https://github.com/fastify/fastify-static",
+ "asOfVersion": "2.2.1"
+ },
{
"libraryName": "fecha",
"typingsPackageName": "fecha",
diff --git a/types/acl/index.d.ts b/types/acl/index.d.ts
index 3f4df31aa2..931452dc52 100644
--- a/types/acl/index.d.ts
+++ b/types/acl/index.d.ts
@@ -1,150 +1,179 @@
-// Type definitions for node_acl 0.4.8
+// Type definitions for acl 0.4
// Project: https://github.com/optimalbits/node_acl
// Definitions by: Qubo
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
///
-///
import http = require('http');
-import Promise = require("bluebird");
-import express = require("express");
+import Promise = require('bluebird');
+import express = require('express');
+import redis = require('redis');
+import mongo = require('mongodb');
-type strings = string|string[];
-type Value = string|number;
-type Values = Value|Value[];
+export = AclStatic;
+
+declare const AclStatic: AclStatic;
+
+type strings = string | string[];
+type Value = string | number;
+type Values = Value | Value[];
type Action = () => any;
-type Callback = (err: Error) => any;
+type Callback = (err?: Error) => any;
type AnyCallback = (err: Error, obj: any) => any;
type AllowedCallback = (err: Error, allowed: boolean) => any;
type GetUserId = (req: http.IncomingMessage, res: http.ServerResponse) => Value;
interface AclStatic {
- new (backend: Backend, logger: Logger, options: Option): Acl;
- new (backend: Backend, logger: Logger): Acl;
- new (backend: Backend): Acl;
- memoryBackend: MemoryBackendStatic;
+ new (
+ backend: AclStatic.Backend,
+ logger?: AclStatic.Logger,
+ options?: AclStatic.Option
+ ): AclStatic.Acl;
+ readonly memoryBackend: AclStatic.MemoryBackendStatic;
+ readonly mongodbBackend: AclStatic.MongodbBackendStatic;
+ readonly redisBackend: AclStatic.RedisBackendStatic;
}
-interface Logger {
- debug: (msg: string) => any;
-}
-
-interface Acl {
- addUserRoles: (userId: Value, roles: strings, cb?: Callback) => Promise;
- removeUserRoles: (userId: Value, roles: strings, cb?: Callback) => Promise;
- userRoles: (userId: Value, cb?: (err: Error, roles: string[]) => any) => Promise;
- roleUsers: (role: Value, cb?: (err: Error, users: Values) => any) => Promise;
- hasRole: (userId: Value, role: string, cb?: (err: Error, isInRole: boolean) => any) => Promise;
- addRoleParents: (role: string, parents: Values, cb?: Callback) => Promise;
- removeRole: (role: string, cb?: Callback) => Promise;
- removeResource: (resource: string, cb?: Callback) => Promise;
- allow: {
- (roles: Values, resources: strings, permissions: strings, cb?: Callback): Promise;
- (aclSets: AclSet | AclSet[]): Promise;
+declare namespace AclStatic {
+ interface Logger {
+ debug: (msg: string) => any;
}
- removeAllow: (role: string, resources: strings, permissions: strings, cb?: Callback) => Promise;
- removePermissions: (role: string, resources: strings, permissions: strings, cb?: Function) => Promise;
- allowedPermissions: (userId: Value, resources: strings, cb?: AnyCallback) => Promise;
- isAllowed: (userId: Value, resources: strings, permissions: strings, cb?: AllowedCallback) => Promise;
- areAnyRolesAllowed: (roles: strings, resource: strings, permissions: strings, cb?: AllowedCallback) => Promise;
- whatResources: {
- (roles: strings, cb?: AnyCallback): Promise;
- (roles: strings, permissions: strings, cb?: AnyCallback): Promise;
+
+ interface Acl {
+ addUserRoles: (userId: Value, roles: strings, cb?: Callback) => Promise;
+ removeUserRoles: (userId: Value, roles: strings, cb?: Callback) => Promise;
+ userRoles: (userId: Value, cb?: (err: Error, roles: string[]) => any) => Promise;
+ roleUsers: (role: Value, cb?: (err: Error, users: Values) => any) => Promise;
+ hasRole: (
+ userId: Value,
+ role: string,
+ cb?: (err: Error, isInRole: boolean) => any
+ ) => Promise;
+ addRoleParents: (role: string, parents: Values, cb?: Callback) => Promise;
+ removeRole: (role: string, cb?: Callback) => Promise;
+ removeResource: (resource: string, cb?: Callback) => Promise;
+ allow: {
+ (roles: Values, resources: strings, permissions: strings, cb?: Callback): Promise;
+ (aclSets: AclSet | AclSet[]): Promise;
+ };
+ removeAllow: (
+ role: string,
+ resources: strings,
+ permissions: strings,
+ cb?: Callback
+ ) => Promise;
+ removePermissions: (
+ role: string,
+ resources: strings,
+ permissions: strings,
+ cb?: Callback
+ ) => Promise;
+ allowedPermissions: (userId: Value, resources: strings, cb?: AnyCallback) => Promise;
+ isAllowed: (
+ userId: Value,
+ resources: strings,
+ permissions: strings,
+ cb?: AllowedCallback
+ ) => Promise;
+ areAnyRolesAllowed: (
+ roles: strings,
+ resource: strings,
+ permissions: strings,
+ cb?: AllowedCallback
+ ) => Promise;
+ whatResources: {
+ (roles: strings, cb?: AnyCallback): Promise;
+ (roles: strings, permissions: strings, cb?: AnyCallback): Promise;
+ };
+ permittedResources: (roles: strings, permissions: strings, cb?: Callback) => Promise;
+ middleware: (
+ numPathComponents?: number,
+ userId?: Value | GetUserId,
+ actions?: strings
+ ) => express.RequestHandler;
+ }
+
+ interface Option {
+ buckets?: BucketsOption;
+ }
+
+ interface BucketsOption {
+ meta?: string;
+ parents?: string;
+ permissions?: string;
+ resources?: string;
+ roles?: string;
+ users?: string;
+ }
+
+ interface AclSet {
+ roles: strings;
+ allows: AclAllow[];
+ }
+
+ interface AclAllow {
+ resources: strings;
+ permissions: strings;
+ }
+
+ interface MemoryBackend extends Backend {}
+ interface MemoryBackendStatic {
+ new (): MemoryBackend;
+ }
+
+ //
+ // For internal use
+ //
+ interface Backend {
+ begin: () => T;
+ end: (transaction: T, cb?: Action) => void;
+ clean: (cb?: Action) => void;
+ get: (bucket: string, key: Value, cb?: Action) => void;
+ union: (bucket: string, keys: Value[], cb?: Action) => void;
+ add: (transaction: T, bucket: string, key: Value, values: Values) => void;
+ del: (transaction: T, bucket: string, keys: Value[]) => void;
+ remove: (transaction: T, bucket: string, key: Value, values: Values) => void;
+
+ endAsync: (transaction: T, cb?: (err: Error | null) => void) => Promise;
+ getAsync: (
+ bucket: string,
+ key: Value,
+ cb?: (err: Error | null, value: any) => void
+ ) => Promise;
+ cleanAsync: (cb?: (error?: Error) => void) => Promise;
+ unionAsync: (
+ bucket: string,
+ keys: Value[],
+ cb?: (error: Error | undefined, results: any[]) => void
+ ) => Promise;
+ }
+
+ interface Contract {
+ (args: IArguments): Contract | NoOp;
+ debug: boolean;
+ fulfilled: boolean;
+ args: any[];
+ checkedParams: string[];
+ params: (...types: string[]) => Contract | NoOp;
+ end: () => void;
+ }
+
+ interface NoOp {
+ params: (...types: string[]) => NoOp;
+ end: () => void;
+ }
+
+ // for redis backend
+ interface RedisBackend extends Backend {}
+ interface RedisBackendStatic {
+ new (redis: redis.RedisClient, prefix?: string): RedisBackend;
+ }
+
+ // for mongodb backend
+ interface MongodbBackend extends Backend {}
+ interface MongodbBackendStatic {
+ new (db: mongo.Db, prefix?: string, useSingle?: boolean): MongodbBackend;
}
- permittedResources: (roles: strings, permissions: strings, cb?: Function) => Promise;
- middleware: (numPathComponents?: number, userId?: Value | GetUserId, actions?: strings) => express.RequestHandler;
}
-
-interface Option {
- buckets?: BucketsOption;
-}
-
-interface BucketsOption {
- meta?: string;
- parents?: string;
- permissions?: string;
- resources?: string;
- roles?: string;
- users?: string;
-}
-
-interface AclSet {
- roles: strings;
- allows: AclAllow[];
-}
-
-interface AclAllow {
- resources: strings;
- permissions: strings;
-}
-
-interface MemoryBackend extends Backend { }
-interface MemoryBackendStatic {
- new (): MemoryBackend;
-}
-
-//
-// For internal use
-//
-interface Backend {
- begin: () => T;
- end: (transaction: T, cb?: Action) => void;
- clean: (cb?: Action) => void;
- get: (bucket: string, key: Value, cb?: Action) => void;
- union: (bucket: string, keys: Value[], cb?: Action) => void;
- add: (transaction: T, bucket: string, key: Value, values: Values) => void;
- del: (transaction: T, bucket: string, keys: Value[]) => void;
- remove: (transaction: T, bucket: string, key: Value, values: Values) => void;
-
- endAsync: Function; //TODO: Give more specific function signature
- getAsync: Function;
- cleanAsync: Function;
- unionAsync: Function;
-}
-
-interface Contract {
- (args: IArguments): Contract | NoOp;
- debug: boolean;
- fulfilled: boolean;
- args: any[];
- checkedParams: string[];
- params: (...types: string[]) => Contract | NoOp;
- end: () => void;
-}
-
-interface NoOp {
- params: (...types: string[]) => NoOp;
- end: () => void;
-}
-
-// for redis backend
-import redis = require('redis');
-
-interface AclStatic {
- redisBackend: RedisBackendStatic;
-}
-
-interface RedisBackend extends Backend { }
-interface RedisBackendStatic {
- new (redis: redis.RedisClient, prefix: string): RedisBackend;
- new (redis: redis.RedisClient): RedisBackend;
-}
-
-// for mongodb backend
-import mongo = require('mongodb');
-
-interface AclStatic {
- mongodbBackend: MongodbBackendStatic;
-}
-
-interface MongodbBackend extends Backend { }
-interface MongodbBackendStatic {
- new (db: mongo.Db, prefix: string, useSingle: boolean): MongodbBackend;
- new (db: mongo.Db, prefix: string): MongodbBackend;
- new (db: mongo.Db): MongodbBackend;
-}
-
-declare var _: AclStatic;
-export = _;
diff --git a/types/acl/test/index.ts b/types/acl/test/index.ts
index bb3e6fa54e..3485ab3662 100644
--- a/types/acl/test/index.ts
+++ b/types/acl/test/index.ts
@@ -2,15 +2,15 @@
// https://github.com/OptimalBits/node_acl/blob/master/Readme.md
import Acl = require('acl');
-var report = (err: Error, value: T) => {
- if (err) {
- console.error(err);
- }
- console.info(value);
+const report = (err: Error, value: any) => {
+ if (err) {
+ console.error(err);
+ }
+ console.info(value);
};
// Using the memory backend
-var acl = new Acl(new Acl.memoryBackend());
+const acl: Acl.Acl = new Acl(new Acl.memoryBackend());
// middleware with no optional parameters
acl.middleware();
@@ -18,11 +18,11 @@ acl.middleware();
acl.middleware(1);
acl.middleware(1, () => {
- return "joed";
+ return 'joed';
});
acl.middleware(1, () => {
- return 2;
+ return 2;
});
acl.middleware(1, 'joed');
@@ -33,36 +33,36 @@ acl.middleware(3, 'joed', 'post');
acl.allow('guest', 'blogs', 'view');
// allow function accepts arrays as any parameter
-acl.allow('member', 'blogs', ['edit','view', 'delete']);
+acl.allow('member', 'blogs', ['edit', 'view', 'delete']);
acl.addUserRoles('joed', 'guest');
-acl.addRoleParents('baz', ['foo','bar']);
+acl.addRoleParents('baz', ['foo', 'bar']);
-acl.allow('foo', ['blogs','forums','news'], ['view', 'delete']);
+acl.allow('foo', ['blogs', 'forums', 'news'], ['view', 'delete']);
-acl.allow('admin', ['blogs','forums'], '*');
+acl.allow('admin', ['blogs', 'forums'], '*');
acl.allow([
{
- roles:['guest','special-member'],
- allows:[
- {resources:'blogs', permissions:'get'},
- {resources:['forums','news'], permissions:['get','put','delete']}
- ]
+ roles: ['guest', 'special-member'],
+ allows: [
+ { resources: 'blogs', permissions: 'get' },
+ { resources: ['forums', 'news'], permissions: ['get', 'put', 'delete'] },
+ ],
},
{
- roles:['gold','silver'],
- allows:[
- {resources:'cash', permissions:['sell','exchange']},
- {resources:['account','deposit'], permissions:['put','delete']}
- ]
- }
+ roles: ['gold', 'silver'],
+ allows: [
+ { resources: 'cash', permissions: ['sell', 'exchange'] },
+ { resources: ['account', 'deposit'], permissions: ['put', 'delete'] },
+ ],
+ },
]);
acl.isAllowed('joed', 'blogs', 'view', (err, res) => {
if (res) {
- console.log("User joed is allowed to view blogs");
+ console.log('User joed is allowed to view blogs');
}
});
@@ -78,15 +78,14 @@ acl.whatResources('foo', 'view', (err, res) => {
}
});
-acl.isAllowed('jsmith', 'blogs', ['edit','view','delete'])
-.then((result) => {
- console.dir('jsmith is allowed blogs ' + result);
- acl.addUserRoles('jsmith', 'member');
-}).then(() =>
- acl.isAllowed('jsmith', 'blogs', ['edit','view','delete'])
-).then((result) =>
- console.dir('jsmith is allowed blogs ' + result)
-).then(() => {
- acl.allowedPermissions('james', ['blogs','forums'], report);
- acl.allowedPermissions('jsmith', ['blogs','forums'], report);
-});
+acl.isAllowed('jsmith', 'blogs', ['edit', 'view', 'delete'])
+ .then(result => {
+ console.dir('jsmith is allowed blogs ' + result);
+ acl.addUserRoles('jsmith', 'member');
+ })
+ .then(() => acl.isAllowed('jsmith', 'blogs', ['edit', 'view', 'delete']))
+ .then(result => console.dir('jsmith is allowed blogs ' + result))
+ .then(() => {
+ acl.allowedPermissions('james', ['blogs', 'forums'], report);
+ acl.allowedPermissions('jsmith', ['blogs', 'forums'], report);
+ });
diff --git a/types/acl/test/mongodbBackend.ts b/types/acl/test/mongodbBackend.ts
index ae3b1d03c9..449cefa030 100644
--- a/types/acl/test/mongodbBackend.ts
+++ b/types/acl/test/mongodbBackend.ts
@@ -5,10 +5,10 @@ import mongodb = require('mongodb');
declare var db: mongodb.Db;
// Using the mongo db backend
-var acl = new Acl(new Acl.mongodbBackend(db, 'acl_', true));
+const acl = new Acl(new Acl.mongodbBackend(db, 'acl_', true));
// guest is allowed to view blogs
acl.allow('guest', 'blogs', 'view');
// allow function accepts arrays as any parameter
-acl.allow('member', 'blogs', ['edit','view', 'delete']);
+acl.allow('member', 'blogs', ['edit', 'view', 'delete']);
diff --git a/types/acl/test/redisBackend.ts b/types/acl/test/redisBackend.ts
index ec1924cce6..669d28ed6d 100644
--- a/types/acl/test/redisBackend.ts
+++ b/types/acl/test/redisBackend.ts
@@ -5,10 +5,10 @@ import redis = require('redis');
declare var client: redis.RedisClient;
// Using the redis backend
-var acl = new Acl(new Acl.redisBackend(client, 'acl_'));
+const acl = new Acl(new Acl.redisBackend(client, 'acl_'));
// guest is allowed to view blogs
acl.allow('guest', 'blogs', 'view');
// allow function accepts arrays as any parameter
-acl.allow('member', 'blogs', ['edit','view', 'delete']);
+acl.allow('member', 'blogs', ['edit', 'view', 'delete']);
diff --git a/types/acl/tslint.json b/types/acl/tslint.json
index a41bf5d19a..f93cf8562a 100644
--- a/types/acl/tslint.json
+++ b/types/acl/tslint.json
@@ -1,79 +1,3 @@
{
- "extends": "dtslint/dt.json",
- "rules": {
- "adjacent-overload-signatures": false,
- "array-type": false,
- "arrow-return-shorthand": false,
- "ban-types": false,
- "callable-types": false,
- "comment-format": false,
- "dt-header": false,
- "eofline": false,
- "export-just-namespace": false,
- "import-spacing": false,
- "interface-name": false,
- "interface-over-type-literal": false,
- "jsdoc-format": false,
- "max-line-length": false,
- "member-access": false,
- "new-parens": false,
- "no-any-union": false,
- "no-boolean-literal-compare": false,
- "no-conditional-assignment": false,
- "no-consecutive-blank-lines": false,
- "no-construct": false,
- "no-declare-current-package": false,
- "no-duplicate-imports": false,
- "no-duplicate-variable": false,
- "no-empty-interface": false,
- "no-for-in-array": false,
- "no-inferrable-types": false,
- "no-internal-module": false,
- "no-irregular-whitespace": false,
- "no-mergeable-namespace": false,
- "no-misused-new": false,
- "no-namespace": false,
- "no-object-literal-type-assertion": false,
- "no-padding": false,
- "no-redundant-jsdoc": false,
- "no-redundant-jsdoc-2": false,
- "no-redundant-undefined": false,
- "no-reference-import": false,
- "no-relative-import-in-test": false,
- "no-self-import": false,
- "no-single-declare-module": false,
- "no-string-throw": false,
- "no-unnecessary-callback-wrapper": false,
- "no-unnecessary-class": false,
- "no-unnecessary-generics": false,
- "no-unnecessary-qualifier": false,
- "no-unnecessary-type-assertion": false,
- "no-useless-files": false,
- "no-var-keyword": false,
- "no-var-requires": false,
- "no-void-expression": false,
- "no-trailing-whitespace": false,
- "object-literal-key-quotes": false,
- "object-literal-shorthand": false,
- "one-line": false,
- "one-variable-per-declaration": false,
- "only-arrow-functions": false,
- "prefer-conditional-expression": false,
- "prefer-const": false,
- "prefer-declare-function": false,
- "prefer-for-of": false,
- "prefer-method-signature": false,
- "prefer-template": false,
- "radix": false,
- "semicolon": false,
- "space-before-function-paren": false,
- "space-within-parens": false,
- "strict-export-declare-modifiers": false,
- "trim-file": false,
- "triple-equals": false,
- "typedef-whitespace": false,
- "unified-signatures": false,
- "void-return": false,
- "whitespace": false
- }
+ "extends": "dtslint/dt.json"
}
diff --git a/types/algoliasearch/index.d.ts b/types/algoliasearch/index.d.ts
index 04291996ba..633b681432 100644
--- a/types/algoliasearch/index.d.ts
+++ b/types/algoliasearch/index.d.ts
@@ -1687,7 +1687,7 @@ declare namespace algoliasearch {
* a list of language ISO codes (as a comma-separated string) for which stop words should be enable
* https://github.com/algolia/algoliasearch-client-js#removestopwords
*/
- removeStopWords?: string[];
+ removeStopWords?: boolean | string[];
/**
* List of attributes on which you want to apply word-splitting ("decompounding") for
* each of the languages supported (German, Dutch, and Finnish as of 05/2018)
diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts
index b83a41a6df..7470fb08bb 100644
--- a/types/angular/angular-tests.ts
+++ b/types/angular/angular-tests.ts
@@ -294,6 +294,14 @@ foo.then((x) => {
x.toFixed();
});
+namespace TestPromiseInterop {
+ declare const promiseInterop: ng.IPromise;
+ const ngStringPromise: ng.IPromise =
+ promiseInterop.then((num) => Promise.resolve(String(num)));
+ const caughtStringPromise: ng.IPromise =
+ promiseInterop.catch((reason) => Promise.resolve('oh noes'));
+}
+
// $q signature tests
namespace TestQ {
interface AbcObject {
diff --git a/types/angular/index.d.ts b/types/angular/index.d.ts
index 4a8b26fba9..0c28ddbf27 100644
--- a/types/angular/index.d.ts
+++ b/types/angular/index.d.ts
@@ -1197,6 +1197,15 @@ declare namespace angular {
* the `notifyCallback` method. The promise can not be resolved or rejected from the
* `notifyCallback` method.
*/
+ then(
+ successCallback?:
+ | ((value: T) => PromiseLike | PromiseLike | TResult1)
+ | null,
+ errorCallback?:
+ | ((reason: any) => PromiseLike | PromiseLike | TResult2)
+ | null,
+ notifyCallback?: (state: any) => any
+ ): IPromise;
then(
successCallback?:
| ((value: T) => IPromise | IPromise | TResult1)
@@ -1210,6 +1219,11 @@ declare namespace angular {
/**
* Shorthand for promise.then(null, errorCallback)
*/
+ catch(
+ onRejected?:
+ | ((reason: any) => PromiseLike | PromiseLike | TResult)
+ | null
+ ): IPromise;
catch(
onRejected?:
| ((reason: any) => IPromise | IPromise | TResult)
diff --git a/types/angular/tsconfig.json b/types/angular/tsconfig.json
index 46eeb69c7a..590c9c7798 100644
--- a/types/angular/tsconfig.json
+++ b/types/angular/tsconfig.json
@@ -11,7 +11,8 @@
"lib": [
"es5",
"dom",
- "es2015.iterable"
+ "es2015.iterable",
+ "es2015.promise"
],
"noImplicitAny": false,
"noImplicitThis": false,
@@ -25,4 +26,4 @@
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
-}
\ No newline at end of file
+}
diff --git a/types/aws-lambda/aws-lambda-tests.ts b/types/aws-lambda/aws-lambda-tests.ts
index ba6ebdc5ac..ad063c20b6 100644
--- a/types/aws-lambda/aws-lambda-tests.ts
+++ b/types/aws-lambda/aws-lambda-tests.ts
@@ -1,12 +1,14 @@
declare let str: string;
declare let strOrNull: string | null;
declare let strOrUndefined: string | undefined;
+declare let strOrUndefinedOrNull: string | undefined | null;
declare let date: Date;
declare let anyObj: any;
declare let num: number;
declare let error: Error;
declare let bool: boolean;
declare let boolOrUndefined: boolean | undefined;
+declare let numOrUndefined: number | undefined;
declare let apiGwEvtReqCtx: AWSLambda.APIGatewayEventRequestContext;
declare let apiGwEvtReqCtxOpt: AWSLambda.APIGatewayEventRequestContext | null | undefined;
declare let apiGwEvt: AWSLambda.APIGatewayEvent;
@@ -80,6 +82,11 @@ declare const scheduledEvent: AWSLambda.ScheduledEvent;
str = apiGwEvtReqCtx.accountId;
str = apiGwEvtReqCtx.apiId;
authResponseContextOpt = apiGwEvtReqCtx.authorizer;
+numOrUndefined = apiGwEvtReqCtx.connectedAt;
+strOrUndefined = apiGwEvtReqCtx.connectionId;
+strOrUndefined = apiGwEvtReqCtx.domainName;
+strOrUndefined = apiGwEvtReqCtx.eventType;
+strOrUndefined = apiGwEvtReqCtx.extendedRequestId;
str = apiGwEvtReqCtx.httpMethod;
strOrNull = apiGwEvtReqCtx.identity.accessKey;
strOrNull = apiGwEvtReqCtx.identity.accountId;
@@ -94,11 +101,15 @@ str = apiGwEvtReqCtx.identity.sourceIp;
strOrNull = apiGwEvtReqCtx.identity.user;
strOrNull = apiGwEvtReqCtx.identity.userAgent;
strOrNull = apiGwEvtReqCtx.identity.userArn;
+strOrUndefined = apiGwEvtReqCtx.messageDirection;
+strOrUndefinedOrNull = apiGwEvtReqCtx.messageId;
str = apiGwEvtReqCtx.path;
str = apiGwEvtReqCtx.stage;
str = apiGwEvtReqCtx.requestId;
+strOrUndefined = apiGwEvtReqCtx.requestTime;
str = apiGwEvtReqCtx.resourceId;
str = apiGwEvtReqCtx.resourcePath;
+strOrUndefined = apiGwEvtReqCtx.routeKey;
/* API Gateway Event */
strOrNull = apiGwEvt.body;
diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts
index 52314529bc..3301feebb5 100644
--- a/types/aws-lambda/index.d.ts
+++ b/types/aws-lambda/index.d.ts
@@ -25,6 +25,7 @@
// Trevor Leach
// James Gregory
// Erik Dalén
+// Loïk Gaonac'h
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -33,6 +34,11 @@ export interface APIGatewayEventRequestContext {
accountId: string;
apiId: string;
authorizer?: AuthResponseContext | null;
+ connectedAt: number;
+ connectionId?: string;
+ domainName?: string;
+ eventType?: string;
+ extendedRequestId?: string;
httpMethod: string;
identity: {
accessKey: string | null;
@@ -49,12 +55,16 @@ export interface APIGatewayEventRequestContext {
userAgent: string | null;
userArn: string | null;
};
+ messageDirection?: string;
+ messageId?: string | null;
path: string;
stage: string;
requestId: string;
+ requestTime?: string;
requestTimeEpoch: number;
resourceId: string;
resourcePath: string;
+ routeKey?: string;
}
// API Gateway "event"
diff --git a/types/aws-param-store/aws-param-store-tests.ts b/types/aws-param-store/aws-param-store-tests.ts
new file mode 100644
index 0000000000..13ad6c0514
--- /dev/null
+++ b/types/aws-param-store/aws-param-store-tests.ts
@@ -0,0 +1,78 @@
+import { SSM } from 'aws-sdk';
+import {
+ ParameterQuery,
+ parameterQuery,
+ getParameter,
+ getParameters,
+ getParametersByPath,
+ getParameterSync,
+ getParametersSync,
+ getParametersByPathSync,
+} from 'aws-param-store';
+
+declare let bool: boolean;
+declare let query: ParameterQuery;
+declare let psName: SSM.Types.PSParameterName;
+declare let psNames: SSM.Types.ParameterNameList;
+declare let options: SSM.Types.ClientConfiguration;
+declare let paramResult: SSM.Types.Parameter;
+declare let paramsResult: SSM.Types.GetParametersResult;
+declare let paramsByPathResult: SSM.Types.ParameterList;
+declare let allParamResults: SSM.Types.Parameter | SSM.Types.GetParametersByPathResult | SSM.Types.ParameterList;
+declare let promiseParamResult: Promise;
+declare let promiseParamsResult: Promise;
+declare let promiseParamsByPathResult: Promise;
+declare let promiseAllParamResults: Promise;
+
+query = parameterQuery();
+
+query.path(psName);
+query.named(psName);
+query.named(psNames);
+query.decryption(bool);
+query.recursive(bool);
+
+promiseAllParamResults = query.execute();
+allParamResults = query.executeSync();
+
+// test chaining
+query = query
+.path(psName)
+.named(psName)
+.named(psNames)
+.decryption(bool)
+.recursive(bool);
+
+promiseAllParamResults = query
+.path(psName)
+.named(psName)
+.named(psNames)
+.decryption(bool)
+.recursive(bool)
+.execute();
+
+allParamResults = query
+.path(psName)
+.named(psName)
+.named(psNames)
+.decryption(bool)
+.recursive(bool)
+.executeSync();
+
+promiseParamResult = getParameter(psName);
+promiseParamResult = getParameter(psName, options);
+
+promiseParamsResult = getParameters(psNames);
+promiseParamsResult = getParameters(psNames, options);
+
+promiseParamsByPathResult = getParametersByPath(psNames);
+promiseParamsByPathResult = getParametersByPath(psNames, options);
+
+paramResult = getParameterSync(psName);
+paramResult = getParameterSync(psName, options);
+
+paramsResult = getParametersSync(psNames);
+paramsResult = getParametersSync(psNames, options);
+
+paramsByPathResult = getParametersByPathSync(psNames);
+paramsByPathResult = getParametersByPathSync(psNames, options);
diff --git a/types/aws-param-store/index.d.ts b/types/aws-param-store/index.d.ts
new file mode 100644
index 0000000000..c35edef688
--- /dev/null
+++ b/types/aws-param-store/index.d.ts
@@ -0,0 +1,48 @@
+// Type definitions for aws-param-store 2.1
+// Project: https://github.com/vandium-io/aws-param-store#readme
+// Definitions by: Jason Gray
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+///
+import { SSM } from 'aws-sdk';
+
+export function getParameter(
+ name: SSM.Types.PSParameterName,
+ options?: SSM.Types.ClientConfiguration
+): Promise;
+
+export function getParameterSync(
+ name: SSM.Types.PSParameterName,
+ options?: SSM.Types.ClientConfiguration
+): SSM.Types.Parameter;
+
+export function getParameters(
+ names: SSM.Types.ParameterNameList,
+ options?: SSM.Types.ClientConfiguration
+): Promise;
+
+export function getParametersSync(
+ names: SSM.Types.ParameterNameList,
+ options?: SSM.Types.ClientConfiguration
+): SSM.Types.GetParametersResult;
+
+export function getParametersByPath(
+ path: SSM.Types.ParameterNameList,
+ options?: SSM.Types.ClientConfiguration
+): Promise;
+
+export function getParametersByPathSync(
+ path: SSM.Types.ParameterNameList,
+ options?: SSM.Types.ClientConfiguration
+): SSM.Types.ParameterList;
+
+export interface ParameterQuery {
+ path(path: SSM.Types.PSParameterName): ParameterQuery;
+ named(nameOrNames: SSM.Types.PSParameterName | SSM.Types.ParameterNameList): ParameterQuery;
+ decryption(enabled: boolean): ParameterQuery;
+ recursive(enabled: boolean): ParameterQuery;
+ execute(): Promise;
+ executeSync(): SSM.Types.ParameterList | SSM.Types.Parameter | SSM.Types.GetParametersResult;
+}
+
+export function parameterQuery(options?: SSM.Types.ClientConfiguration): ParameterQuery;
diff --git a/types/aws-param-store/package.json b/types/aws-param-store/package.json
new file mode 100644
index 0000000000..abb680d4ac
--- /dev/null
+++ b/types/aws-param-store/package.json
@@ -0,0 +1,6 @@
+{
+ "private": true,
+ "dependencies": {
+ "aws-sdk": "^2.325.0"
+ }
+}
diff --git a/types/aws-param-store/tsconfig.json b/types/aws-param-store/tsconfig.json
new file mode 100644
index 0000000000..2857e45680
--- /dev/null
+++ b/types/aws-param-store/tsconfig.json
@@ -0,0 +1,23 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "lib": [
+ "es6"
+ ],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": true,
+ "strictFunctionTypes": true,
+ "baseUrl": "../",
+ "typeRoots": [
+ "../"
+ ],
+ "types": [],
+ "noEmit": true,
+ "forceConsistentCasingInFileNames": true
+ },
+ "files": [
+ "index.d.ts",
+ "aws-param-store-tests.ts"
+ ]
+}
diff --git a/types/fastify-cors/tslint.json b/types/aws-param-store/tslint.json
similarity index 100%
rename from types/fastify-cors/tslint.json
rename to types/aws-param-store/tslint.json
diff --git a/types/backbone-relational/backbone-relational-tests.ts b/types/backbone-relational/backbone-relational-tests.ts
index 6e0135fcd9..c8b94c4029 100644
--- a/types/backbone-relational/backbone-relational-tests.ts
+++ b/types/backbone-relational/backbone-relational-tests.ts
@@ -1,13 +1,13 @@
-import * as Backbone from 'backbone';
+import * as BackboneRel from 'backbone-relational';
-class House extends Backbone.RelationalModel {
+class House extends BackboneRel.Model {
// The 'relations' property, on the House's prototype. Initialized separately for each
// instance of House. Each relation must define (as a minimum) the 'type', 'key' and
// 'relatedModel'. Options include 'includeInJSON', 'createModels' and 'reverseRelation'.
relations = [
{
- type: Backbone.HasMany, // Use the type, or the string 'HasOne' or 'HasMany'.
+ type: BackboneRel.HasMany, // Use the type, or the string 'HasOne' or 'HasMany'.
key: 'occupants',
relatedModel: 'Person',
includeInJSON: true,
@@ -20,14 +20,14 @@ class House extends Backbone.RelationalModel {
}
-class Person extends Backbone.RelationalModel {
+class Person extends BackboneRel.Model {
relations = [
{ // Create a (recursive) one-to-one relationship
- type: Backbone.HasOne,
+ type: BackboneRel.HasOne,
key: 'user',
relatedModel: 'User',
reverseRelation: {
- type: Backbone.HasOne,
+ type: BackboneRel.HasOne,
key: 'person'
}
}
@@ -39,7 +39,7 @@ class Person extends Backbone.RelationalModel {
}
}
-class User extends Backbone.RelationalModel {
+class User extends BackboneRel.Model {
}
diff --git a/types/backbone-relational/index.d.ts b/types/backbone-relational/index.d.ts
index 84406fb60a..f19cfa8daa 100644
--- a/types/backbone-relational/index.d.ts
+++ b/types/backbone-relational/index.d.ts
@@ -1,15 +1,16 @@
-// Type definitions for Backbone-relational 0.8.5
+// Type definitions for Backbone-relational 0.10.0
// Project: http://backbonerelational.org/
// Definitions by: Eirik Hoem
+// Julian Gonggrijp
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
///
-import * as Backbone from 'backbone';
+import { Events, EventsHash, Model as BModel, Collection } from 'backbone';
-declare module 'backbone' {
- class RelationalModel extends Model {
+declare module 'backbone-relational' {
+ class Model extends BModel {
/**
* Do not use, prefer TypeScript's extend functionality.
**/
@@ -47,7 +48,7 @@ declare module 'backbone' {
static findOrCreate(attributes:any, options?:any);
}
- export class Relation extends Model {
+ export class Relation extends BModel {
options:any;
instance:any;
@@ -60,11 +61,11 @@ declare module 'backbone' {
checkPreconditions():boolean;
- setRelated(related:Model):void;
+ setRelated(related:BModel):void;
- setRelated(related:Collection):void;
+ setRelated(related:Collection):void;
- getReverseRelations(model:RelationalModel):Relation;
+ getReverseRelations(model:Model):Relation;
destroy():void;
}
@@ -72,7 +73,7 @@ declare module 'backbone' {
export class HasOne extends Relation {
collectionType:any;
- findRelated(options:any):Model;
+ findRelated(options:any):BModel;
setKeyContents(keyContents:string):void;
@@ -82,21 +83,21 @@ declare module 'backbone' {
setKeyContents(keyContents:number[]):void;
- setKeyContents(keyContents:Collection):void;
+ setKeyContents(keyContents:Collection):void;
- onChange(model:Model, attr:any, options:any):void;
+ onChange(model:BModel, attr:any, options:any):void;
- handleAddition(model:Model, coll:Collection, options:any):void;
+ handleAddition(model:BModel, coll:Collection, options:any):void;
- handleRemoval(model:Model, coll:Collection, options:any):void;
+ handleRemoval(model:BModel, coll:Collection, options:any):void;
- handleReset(coll:Collection, options:any):void;
+ handleReset(coll:Collection, options:any):void;
- tryAddRelated(model:Model, coll:any, options:any):void;
+ tryAddRelated(model:BModel, coll:any, options:any):void;
- addRelated(model:Model, options:any):void;
+ addRelated(model:BModel, options:any):void;
- removeRelated(model:Model, coll:any, options:any):void;
+ removeRelated(model:BModel, coll:any, options:any):void;
}
@@ -104,21 +105,21 @@ declare module 'backbone' {
export class HasMany extends Relation {
collectionType:any;
- findRelated(options:any):Model;
+ findRelated(options:any):BModel;
setKeyContents(keyContents:string):void;
setKeyContents(keyContents:number):void;
- setKeyContents(keyContents:Model):void;
+ setKeyContents(keyContents:BModel):void;
- onChange(model:Model, attr:any, options:any):void;
+ onChange(model:BModel, attr:any, options:any):void;
- tryAddRelated(model:Model, coll:any, options:any):void;
+ tryAddRelated(model:BModel, coll:any, options:any):void;
- addRelated(model:Model, options:any):void;
+ addRelated(model:BModel, options:any):void;
- removeRelated(model:Model, coll:any, options:any):void;
+ removeRelated(model:BModel, coll:any, options:any):void;
}
@@ -141,9 +142,9 @@ declare module 'backbone' {
removeModelScope(scope):void;
- addSubModels(subModelTypes:RelationalModel, superModelType:RelationalModel):void;
+ addSubModels(subModelTypes:Model, superModelType:Model):void;
- setupSuperModel(modelType:RelationalModel):void;
+ setupSuperModel(modelType:Model):void;
addReverseRelation(relation:any):void;
@@ -151,30 +152,30 @@ declare module 'backbone' {
processOrphanRelations():void;
- retroFitRelation(relation:RelationalModel, create:boolean):Collection;
+ retroFitRelation(relation:Model, create:boolean):Collection;
- getCollection(type:RelationalModel, create:boolean):Collection;
+ getCollection(type:Model, create:boolean):Collection;
getObjectByName(name:string):any;
resolveIdForItem(type:any, item:any):any;
- static find(type:any, item:string):RelationalModel;
+ static find(type:any, item:string):Model;
- static find(type:any, item:number):RelationalModel;
+ static find(type:any, item:number):Model;
- static find(type:any, item:RelationalModel):RelationalModel;
+ static find(type:any, item:Model):Model;
- static find(type:any, item:any):RelationalModel;
+ static find(type:any, item:any):Model;
- register(model:RelationalModel):void;
+ register(model:Model):void;
- checkId(model:RelationalModel, id:any):void;
+ checkId(model:Model, id:any):void;
- update(model:RelationalModel):void;
+ update(model:Model):void;
- unregister(model:RelationalModel, collection:Collection, options:any):void;
+ unregister(model:Model, collection:Collection, options:any):void;
reset():void;
diff --git a/types/bull/index.d.ts b/types/bull/index.d.ts
index bbafa0301c..aab2385ea4 100644
--- a/types/bull/index.d.ts
+++ b/types/bull/index.d.ts
@@ -228,6 +228,25 @@ declare namespace Bull {
* Takes a lock for this job so that no other queue worker can process it at the same time.
*/
takeLock(): Promise;
+
+ /**
+ * Get job properties as Json Object
+ */
+ toJSON(): {
+ id: JobId,
+ name: string,
+ data: T,
+ opts: JobOptions,
+ progress: number,
+ delay: number,
+ timestamp: number,
+ attemptsMade: number,
+ failedReason: any,
+ stacktrace: string[] | null,
+ returnvalue: any,
+ finishedOn: number | null,
+ processedOn: number | null
+ };
}
type JobStatus = 'completed' | 'waiting' | 'active' | 'delayed' | 'failed';
diff --git a/types/bunyan-seq/bunyan-seq-tests.ts b/types/bunyan-seq/bunyan-seq-tests.ts
new file mode 100644
index 0000000000..beeeb9d8ee
--- /dev/null
+++ b/types/bunyan-seq/bunyan-seq-tests.ts
@@ -0,0 +1,2 @@
+import bunyanSeq = require("bunyan-seq");
+bunyanSeq.createStream({name: 'LoggerComponent', serverUrl: 'http://seq.com'});
diff --git a/types/bunyan-seq/index.d.ts b/types/bunyan-seq/index.d.ts
new file mode 100644
index 0000000000..2520c93339
--- /dev/null
+++ b/types/bunyan-seq/index.d.ts
@@ -0,0 +1,21 @@
+// Type definitions for bunyan-blackhole 0.2
+// Project: https://github.com/datalust/bunyan-seq
+// Definitions by: Ray Booysen
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// TypeScript Version: 2.1
+
+///
+import * as Logger from "bunyan";
+export interface Configuration {
+ apiKey?: string;
+ batchSizeLimit?: number;
+ eventSizeLimit?: number;
+ level?: string;
+ maxBatchingTime?: number;
+ name?: string;
+ onError?: (e: Error) => void;
+ reemitErrorEvents?: boolean;
+ serverUrl?: string;
+}
+
+export function createStream(config: Configuration): Logger.Stream;
diff --git a/types/fastify-cors/tsconfig.json b/types/bunyan-seq/tsconfig.json
similarity index 93%
rename from types/fastify-cors/tsconfig.json
rename to types/bunyan-seq/tsconfig.json
index 9e696b42e2..bd77368148 100644
--- a/types/fastify-cors/tsconfig.json
+++ b/types/bunyan-seq/tsconfig.json
@@ -18,6 +18,6 @@
},
"files": [
"index.d.ts",
- "fastify-cors-tests.ts"
+ "bunyan-seq-tests.ts"
]
}
diff --git a/types/fastify-static/tslint.json b/types/bunyan-seq/tslint.json
similarity index 100%
rename from types/fastify-static/tslint.json
rename to types/bunyan-seq/tslint.json
diff --git a/types/carbon__colors/carbon__colors-tests.ts b/types/carbon__colors/carbon__colors-tests.ts
new file mode 100644
index 0000000000..1df2cea931
--- /dev/null
+++ b/types/carbon__colors/carbon__colors-tests.ts
@@ -0,0 +1,3 @@
+import { rgba } from "@carbon/colors";
+
+rgba("TOTORO", 0.4); // $ExpectType string
diff --git a/types/carbon__colors/index.d.ts b/types/carbon__colors/index.d.ts
new file mode 100644
index 0000000000..33438d7c66
--- /dev/null
+++ b/types/carbon__colors/index.d.ts
@@ -0,0 +1,491 @@
+// Type definitions for @carbon/colors 0.0
+// Project: https://github.com/IBM/carbon-elements/tree/master/packages/colors
+// Definitions by: Vince Picone
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+export const black: string;
+
+export const black100: string;
+
+export const blue: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+};
+
+export const blue10: string;
+
+export const blue100: string;
+
+export const blue20: string;
+
+export const blue30: string;
+
+export const blue40: string;
+
+export const blue50: string;
+
+export const blue60: string;
+
+export const blue70: string;
+
+export const blue80: string;
+
+export const blue90: string;
+
+export const colors: {
+ black: {
+ "100": string;
+ };
+ blue: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+ };
+ coolGray: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+ };
+ cyan: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+ };
+ gray: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+ };
+ green: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+ };
+ magenta: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+ };
+ orange: {
+ "40": string;
+ };
+ purple: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+ };
+ red: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+ };
+ teal: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+ };
+ warmGray: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+ };
+ white: {
+ "0": string;
+ };
+ yellow: {
+ "20": string;
+ };
+};
+
+export const coolGray: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+};
+
+export const coolGray10: string;
+
+export const coolGray100: string;
+
+export const coolGray20: string;
+
+export const coolGray30: string;
+
+export const coolGray40: string;
+
+export const coolGray50: string;
+
+export const coolGray60: string;
+
+export const coolGray70: string;
+
+export const coolGray80: string;
+
+export const coolGray90: string;
+
+export const cyan: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+};
+
+export const cyan10: string;
+
+export const cyan100: string;
+
+export const cyan20: string;
+
+export const cyan30: string;
+
+export const cyan40: string;
+
+export const cyan50: string;
+
+export const cyan60: string;
+
+export const cyan70: string;
+
+export const cyan80: string;
+
+export const cyan90: string;
+
+export const gray: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+};
+
+export const gray10: string;
+
+export const gray100: string;
+
+export const gray20: string;
+
+export const gray30: string;
+
+export const gray40: string;
+
+export const gray50: string;
+
+export const gray60: string;
+
+export const gray70: string;
+
+export const gray80: string;
+
+export const gray90: string;
+
+export const green: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+};
+
+export const green10: string;
+
+export const green100: string;
+
+export const green20: string;
+
+export const green30: string;
+
+export const green40: string;
+
+export const green50: string;
+
+export const green60: string;
+
+export const green70: string;
+
+export const green80: string;
+
+export const green90: string;
+
+export const magenta: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+};
+
+export const magenta10: string;
+
+export const magenta100: string;
+
+export const magenta20: string;
+
+export const magenta30: string;
+
+export const magenta40: string;
+
+export const magenta50: string;
+
+export const magenta60: string;
+
+export const magenta70: string;
+
+export const magenta80: string;
+
+export const magenta90: string;
+
+export const orange: string;
+
+export const orange40: string;
+
+export const purple: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+};
+
+export const purple10: string;
+
+export const purple100: string;
+
+export const purple20: string;
+
+export const purple30: string;
+
+export const purple40: string;
+
+export const purple50: string;
+
+export const purple60: string;
+
+export const purple70: string;
+
+export const purple80: string;
+
+export const purple90: string;
+
+export const red: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+};
+
+export const red10: string;
+
+export const red100: string;
+
+export const red20: string;
+
+export const red30: string;
+
+export const red40: string;
+
+export const red50: string;
+
+export const red60: string;
+
+export const red70: string;
+
+export const red80: string;
+
+export const red90: string;
+
+export const teal: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+};
+
+export const teal10: string;
+
+export const teal100: string;
+
+export const teal20: string;
+
+export const teal30: string;
+
+export const teal40: string;
+
+export const teal50: string;
+
+export const teal60: string;
+
+export const teal70: string;
+
+export const teal80: string;
+
+export const teal90: string;
+
+export const warmGray: {
+ "10": string;
+ "100": string;
+ "20": string;
+ "30": string;
+ "40": string;
+ "50": string;
+ "60": string;
+ "70": string;
+ "80": string;
+ "90": string;
+};
+
+export const warmGray10: string;
+
+export const warmGray100: string;
+
+export const warmGray20: string;
+
+export const warmGray30: string;
+
+export const warmGray40: string;
+
+export const warmGray50: string;
+
+export const warmGray60: string;
+
+export const warmGray70: string;
+
+export const warmGray80: string;
+
+export const warmGray90: string;
+
+export const white: string;
+
+export const white0: string;
+
+export const yellow: string;
+
+export const yellow20: string;
+
+export function rgba(hexcode: string, opacity: number): string;
+
+export namespace rgba {
+ const prototype: {};
+}
diff --git a/types/carbon__colors/tsconfig.json b/types/carbon__colors/tsconfig.json
new file mode 100644
index 0000000000..3b03be1aae
--- /dev/null
+++ b/types/carbon__colors/tsconfig.json
@@ -0,0 +1,19 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "lib": ["es6"],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": true,
+ "baseUrl": "../",
+ "typeRoots": ["../"],
+ "types": [],
+ "noEmit": true,
+ "forceConsistentCasingInFileNames": true,
+ "strictFunctionTypes": true,
+ "paths": {
+ "@carbon/colors": ["carbon__colors"]
+ }
+ },
+ "files": ["index.d.ts", "carbon__colors-tests.ts"]
+}
diff --git a/types/carbon__colors/tslint.json b/types/carbon__colors/tslint.json
new file mode 100644
index 0000000000..3db14f85ea
--- /dev/null
+++ b/types/carbon__colors/tslint.json
@@ -0,0 +1 @@
+{ "extends": "dtslint/dt.json" }
diff --git a/types/carbon__layout/carbon__layout-tests.ts b/types/carbon__layout/carbon__layout-tests.ts
new file mode 100644
index 0000000000..ef002f50ae
--- /dev/null
+++ b/types/carbon__layout/carbon__layout-tests.ts
@@ -0,0 +1,20 @@
+import {
+ rem,
+ em,
+ px,
+ breakpoint,
+ breakpoints,
+ breakpointDown,
+ breakpointUp,
+ baseFontSize
+} from "@carbon/layout";
+
+const firstBreakpoint = Object.keys(breakpoints)[0];
+
+rem(baseFontSize); // $ExpectType string
+em(baseFontSize); // $ExpectType string
+px(baseFontSize); // $ExpectType string
+
+breakpoint(firstBreakpoint); // $ExpectType string
+breakpointUp(firstBreakpoint); // $ExpectType string
+breakpointDown(firstBreakpoint); // $ExpectType string
diff --git a/types/carbon__layout/index.d.ts b/types/carbon__layout/index.d.ts
new file mode 100644
index 0000000000..1d7c7b4630
--- /dev/null
+++ b/types/carbon__layout/index.d.ts
@@ -0,0 +1,80 @@
+// Type definitions for @carbon/layout 0.0
+// Project: https://github.com/IBM/carbon-elements/tree/master/packages/layout
+// Definitions by: Vince Picone
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+export const baseFontSize: number;
+
+export const breakpoints: {
+ lg: {
+ columns: number;
+ margin: string;
+ width: string;
+ };
+ max: {
+ columns: number;
+ margin: string;
+ width: string;
+ };
+ md: {
+ columns: number;
+ margin: string;
+ width: string;
+ };
+ sm: {
+ columns: number;
+ margin: string;
+ width: string;
+ };
+ xlg: {
+ columns: number;
+ margin: string;
+ width: string;
+ };
+};
+
+export const miniUnit: number;
+
+export const spacing: number[];
+
+export function breakpoint(...args: any[]): string;
+
+export function breakpointDown(name: string): string;
+
+export function breakpointUp(name: string): string;
+
+export function em(px: number): string;
+
+export function miniUnits(count: number): string;
+
+export function px(value: number): string;
+
+export function rem(px: number): string;
+
+export namespace breakpoint {
+ const prototype: {};
+}
+
+export namespace breakpointDown {
+ const prototype: {};
+}
+
+export namespace breakpointUp {
+ const prototype: {};
+}
+
+export namespace em {
+ const prototype: {};
+}
+
+export namespace miniUnits {
+ const prototype: {};
+}
+
+export namespace px {
+ const prototype: {};
+}
+
+export namespace rem {
+ const prototype: {};
+}
diff --git a/types/carbon__layout/tsconfig.json b/types/carbon__layout/tsconfig.json
new file mode 100644
index 0000000000..10f832a631
--- /dev/null
+++ b/types/carbon__layout/tsconfig.json
@@ -0,0 +1,19 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "lib": ["es6"],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": true,
+ "strictFunctionTypes": true,
+ "baseUrl": "../",
+ "typeRoots": ["../"],
+ "types": [],
+ "noEmit": true,
+ "forceConsistentCasingInFileNames": true,
+ "paths": {
+ "@carbon/layout": ["carbon__layout"]
+ }
+ },
+ "files": ["index.d.ts", "carbon__layout-tests.ts"]
+}
diff --git a/types/carbon__layout/tslint.json b/types/carbon__layout/tslint.json
new file mode 100644
index 0000000000..3db14f85ea
--- /dev/null
+++ b/types/carbon__layout/tslint.json
@@ -0,0 +1 @@
+{ "extends": "dtslint/dt.json" }
diff --git a/types/carbon__motion/carbon__motion-tests.ts b/types/carbon__motion/carbon__motion-tests.ts
new file mode 100644
index 0000000000..6bcc820f5d
--- /dev/null
+++ b/types/carbon__motion/carbon__motion-tests.ts
@@ -0,0 +1,8 @@
+import { easings, motion } from "@carbon/motion";
+
+const easingNames = Object.keys(easings);
+
+const firstEasing = easingNames[0];
+const firstMode = Object.keys(firstEasing)[0];
+
+motion(firstEasing, firstMode);
diff --git a/types/carbon__motion/index.d.ts b/types/carbon__motion/index.d.ts
new file mode 100644
index 0000000000..173687d04c
--- /dev/null
+++ b/types/carbon__motion/index.d.ts
@@ -0,0 +1,25 @@
+// Type definitions for @carbon/motion 0.0
+// Project: https://github.com/IBM/carbon-elements/tree/master/packages/motion
+// Definitions by: Vince Picone
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+export const easings: {
+ entrance: {
+ expressive: string;
+ productive: string;
+ };
+ exit: {
+ expressive: string;
+ productive: string;
+ };
+ standard: {
+ expressive: string;
+ productive: string;
+ };
+};
+
+export function motion(name: string, mode: string): string;
+
+export namespace motion {
+ const prototype: {};
+}
diff --git a/types/carbon__motion/tsconfig.json b/types/carbon__motion/tsconfig.json
new file mode 100644
index 0000000000..38245c7c9e
--- /dev/null
+++ b/types/carbon__motion/tsconfig.json
@@ -0,0 +1,19 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "lib": ["es6"],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": true,
+ "strictFunctionTypes": true,
+ "baseUrl": "../",
+ "typeRoots": ["../"],
+ "types": [],
+ "noEmit": true,
+ "forceConsistentCasingInFileNames": true,
+ "paths": {
+ "@carbon/motion": ["carbon__motion"]
+ }
+ },
+ "files": ["index.d.ts", "carbon__motion-tests.ts"]
+}
diff --git a/types/carbon__motion/tslint.json b/types/carbon__motion/tslint.json
new file mode 100644
index 0000000000..3db14f85ea
--- /dev/null
+++ b/types/carbon__motion/tslint.json
@@ -0,0 +1 @@
+{ "extends": "dtslint/dt.json" }
diff --git a/types/carbon__themes/carbon__themes-tests.ts b/types/carbon__themes/carbon__themes-tests.ts
new file mode 100644
index 0000000000..7515742031
--- /dev/null
+++ b/types/carbon__themes/carbon__themes-tests.ts
@@ -0,0 +1,59 @@
+import ThemePackage from "@carbon/themes";
+
+interface Theme {
+ active01: string;
+ activeDanger: string;
+ activePrimary: string;
+ activeSecondary: string;
+ activeTertiary: string;
+ activeUI: string;
+ brand01: string;
+ brand02: string;
+ brand03: string;
+ disabled01: string;
+ disabled02: string;
+ disabled03: string;
+ field01: string;
+ field02: string;
+ focus: string;
+ highlight: string;
+ hoverDanger: string;
+ hoverField: string;
+ hoverPrimary: string;
+ hoverPrimaryText: string;
+ hoverRow: string;
+ hoverSecondary: string;
+ hoverSelectedUI: string;
+ hoverTertiary: string;
+ hoverUI: string;
+ icon01: string;
+ icon02: string;
+ interactive01: string;
+ interactive02: string;
+ interactive03: string;
+ inverse01: string;
+ inverse02: string;
+ overlay01: string;
+ selectedUI: string;
+ support01: string;
+ support02: string;
+ support03: string;
+ support04: string;
+ text01: string;
+ text02: string;
+ text03: string;
+ text04: string;
+ ui01: string;
+ ui02: string;
+ ui03: string;
+ ui04: string;
+ ui05: string;
+ uiBackground: string;
+ visitedLink: string;
+}
+
+const getDefaultTheme = (): Theme => {
+ return ThemePackage.white;
+};
+
+getDefaultTheme();
diff --git a/types/carbon__themes/index.d.ts b/types/carbon__themes/index.d.ts
new file mode 100644
index 0000000000..e10f17f35c
--- /dev/null
+++ b/types/carbon__themes/index.d.ts
@@ -0,0 +1,74 @@
+// Type definitions for @carbon/themes 0.0
+// Project: https://github.com/IBM/carbon-elements/tree/master/packages/themes
+// Definitions by: Vince Picone
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+export default carbon__themes;
+
+interface Theme {
+ active01: string;
+ activeDanger: string;
+ activePrimary: string;
+ activeSecondary: string;
+ activeTertiary: string;
+ activeUI: string;
+ brand01: string;
+ brand02: string;
+ brand03: string;
+ disabled01: string;
+ disabled02: string;
+ disabled03: string;
+ field01: string;
+ field02: string;
+ focus: string;
+ highlight: string;
+ hoverDanger: string;
+ hoverField: string;
+ hoverPrimary: string;
+ hoverPrimaryText: string;
+ hoverRow: string;
+ hoverSecondary: string;
+ hoverSelectedUI: string;
+ hoverTertiary: string;
+ hoverUI: string;
+ icon01: string;
+ icon02: string;
+ interactive01: string;
+ interactive02: string;
+ interactive03: string;
+ inverse01: string;
+ inverse02: string;
+ overlay01: string;
+ selectedUI: string;
+ support01: string;
+ support02: string;
+ support03: string;
+ support04: string;
+ text01: string;
+ text02: string;
+ text03: string;
+ text04: string;
+ ui01: string;
+ ui02: string;
+ ui03: string;
+ ui04: string;
+ ui05: string;
+ uiBackground: string;
+ visitedLink: string;
+}
+
+// The default theme is included as a top level export
+type ThemePackage = {
+ white: Theme;
+ g10: Theme;
+ g100: Theme;
+ g90: Theme;
+ themes: {
+ g10: Theme;
+ g100: Theme;
+ g90: Theme;
+ white: Theme;
+ };
+} & Theme;
+
+declare const carbon__themes: ThemePackage;
diff --git a/types/carbon__themes/tsconfig.json b/types/carbon__themes/tsconfig.json
new file mode 100644
index 0000000000..490b17648e
--- /dev/null
+++ b/types/carbon__themes/tsconfig.json
@@ -0,0 +1,19 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "lib": ["es6"],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": true,
+ "strictFunctionTypes": true,
+ "baseUrl": "../",
+ "typeRoots": ["../"],
+ "types": [],
+ "noEmit": true,
+ "forceConsistentCasingInFileNames": true,
+ "paths": {
+ "@carbon/themes": ["carbon__themes"]
+ }
+ },
+ "files": ["index.d.ts", "carbon__themes-tests.ts"]
+}
diff --git a/types/carbon__themes/tslint.json b/types/carbon__themes/tslint.json
new file mode 100644
index 0000000000..3db14f85ea
--- /dev/null
+++ b/types/carbon__themes/tslint.json
@@ -0,0 +1 @@
+{ "extends": "dtslint/dt.json" }
diff --git a/types/carbon__type/carbon__type-tests.ts b/types/carbon__type/carbon__type-tests.ts
new file mode 100644
index 0000000000..a5d4cf7b8b
--- /dev/null
+++ b/types/carbon__type/carbon__type-tests.ts
@@ -0,0 +1,6 @@
+import { fontFamily, fontWeight, getTypeSize, print } from "@carbon/type";
+
+fontFamily("mono"); // $ExpectType { fontFamily: string; }
+fontWeight("light"); // $ExpectType { fontWeight: number; }
+print(fontFamily("mono")); // $ExpectType string
+getTypeSize(2); // $ExpectType number
diff --git a/types/carbon__type/index.d.ts b/types/carbon__type/index.d.ts
new file mode 100644
index 0000000000..7933f2e358
--- /dev/null
+++ b/types/carbon__type/index.d.ts
@@ -0,0 +1,726 @@
+// Type definitions for @carbon/type 0.0
+// Project: https://github.com/IBM/carbon-elements/tree/master/packages/type
+// Definitions by: Vince Picone
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// TypeScript Version: 2.2
+
+export const bodyLong01: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: string;
+ lineHeight: string;
+};
+
+export const bodyLong02: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+};
+
+export const bodyShort01: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: string;
+ lineHeight: string;
+};
+
+export const bodyShort02: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+};
+
+export const caption01: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: string;
+ lineHeight: string;
+};
+
+export const code01: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: string;
+ lineHeight: string;
+};
+
+export const code02: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: string;
+ lineHeight: string;
+};
+
+export const display01: {
+ "@media (min-width: 42rem)": {
+ fontSize: string;
+ };
+ "@media (min-width: 66rem)": {
+ fontSize: string;
+ };
+ "@media (min-width: 82rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+};
+
+export const display02: {
+ "@media (min-width: 42rem)": {
+ fontSize: string;
+ };
+ "@media (min-width: 66rem)": {
+ fontSize: string;
+ };
+ "@media (min-width: 82rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+};
+
+export const display03: {
+ "@media (min-width: 42rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 66rem)": {
+ fontSize: string;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 82rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontSize: string;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+};
+
+export const display04: {
+ "@media (min-width: 42rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 66rem)": {
+ fontSize: string;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 82rem)": {
+ fontSize: string;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontSize: string;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+};
+
+export const expressiveHeading04: {
+ "@media (min-width: 82rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontSize: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+};
+
+export const expressiveHeading05: {
+ "@media (min-width: 42rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ "@media (min-width: 66rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ "@media (min-width: 82rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+};
+
+export const expressiveParagraph01: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lg: {
+ fontSize: string;
+ lineHeight: string;
+ };
+ lineHeight: string;
+ max: {
+ fontSize: string;
+ lineHeight: string;
+ };
+};
+
+export const fontFamilies: {
+ mono: string;
+ sans: string;
+ sansCondensed: string;
+ sansHebrew: string;
+ serif: string;
+};
+
+export const fontWeights: {
+ light: number;
+ regular: number;
+ semibold: number;
+};
+
+export const heading01: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: string;
+ lineHeight: string;
+};
+
+export const heading02: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+};
+
+export const heading03: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+};
+
+export const helperText01: {
+ fontFamily: string;
+ fontSize: string;
+ fontStyle: string;
+ letterSpacing: string;
+ lineHeight: string;
+};
+
+export const label01: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: string;
+ lineHeight: string;
+};
+
+export const productiveHeading04: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+};
+
+export const productiveHeading05: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+};
+
+export const quotation01: {
+ "@media (min-width: 42rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ };
+ "@media (min-width: 66rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ "@media (min-width: 82rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+};
+
+export const quotation02: {
+ "@media (min-width: 42rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 66rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 82rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontSize: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+};
+
+export const reset: {
+ body: {
+ "-moz-osx-font-smoothing": string;
+ "-webkit-font-smoothing": string;
+ fontFamily: string;
+ fontWeight: number;
+ textRendering: string;
+ };
+ html: {
+ fontSize: string;
+ };
+ strong: {
+ fontWeight: number;
+ };
+};
+
+export const scale: number[];
+
+export const spacing: {
+ layout01: string;
+ layout02: string;
+ layout03: string;
+ margin01: string;
+ margin02: string;
+ margin03: string;
+};
+
+export const styles: {
+ bodyLong01: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ bodyLong02: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ bodyShort01: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ bodyShort02: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ caption01: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ code01: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ code02: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ display01: {
+ "@media (min-width: 42rem)": {
+ fontSize: string;
+ };
+ "@media (min-width: 66rem)": {
+ fontSize: string;
+ };
+ "@media (min-width: 82rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ display02: {
+ "@media (min-width: 42rem)": {
+ fontSize: string;
+ };
+ "@media (min-width: 66rem)": {
+ fontSize: string;
+ };
+ "@media (min-width: 82rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ display03: {
+ "@media (min-width: 42rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 66rem)": {
+ fontSize: string;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 82rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontSize: string;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ display04: {
+ "@media (min-width: 42rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 66rem)": {
+ fontSize: string;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 82rem)": {
+ fontSize: string;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontSize: string;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ expressiveHeading04: {
+ "@media (min-width: 82rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontSize: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ expressiveHeading05: {
+ "@media (min-width: 42rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ "@media (min-width: 66rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ "@media (min-width: 82rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ expressiveParagraph01: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lg: {
+ fontSize: string;
+ lineHeight: string;
+ };
+ lineHeight: string;
+ max: {
+ fontSize: string;
+ lineHeight: string;
+ };
+ };
+ heading01: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ heading02: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ heading03: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ helperText01: {
+ fontFamily: string;
+ fontSize: string;
+ fontStyle: string;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ label01: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: string;
+ lineHeight: string;
+ };
+ productiveHeading04: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ productiveHeading05: {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ quotation01: {
+ "@media (min-width: 42rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ };
+ "@media (min-width: 66rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ "@media (min-width: 82rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+ quotation02: {
+ "@media (min-width: 42rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 66rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 82rem)": {
+ fontSize: string;
+ lineHeight: string;
+ };
+ "@media (min-width: 99rem)": {
+ fontSize: string;
+ };
+ fontFamily: string;
+ fontSize: string;
+ fontWeight: number;
+ letterSpacing: number;
+ lineHeight: string;
+ };
+};
+
+export function fontFamily(
+ name: string
+): {
+ fontFamily: string;
+};
+
+export function fontWeight(
+ weight: string
+): {
+ fontWeight: number;
+};
+
+export function getTypeSize(step: number): number;
+
+export function print(block: object): string;
+
+export namespace fontFamily {
+ const prototype: {};
+}
+
+export namespace fontWeight {
+ const prototype: {};
+}
+
+export namespace getTypeSize {
+ const prototype: {};
+}
+
+export namespace print {
+ const prototype: {};
+}
diff --git a/types/carbon__type/tsconfig.json b/types/carbon__type/tsconfig.json
new file mode 100644
index 0000000000..7949e7ab22
--- /dev/null
+++ b/types/carbon__type/tsconfig.json
@@ -0,0 +1,19 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "lib": ["es6"],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": true,
+ "strictFunctionTypes": true,
+ "baseUrl": "../",
+ "typeRoots": ["../"],
+ "types": [],
+ "noEmit": true,
+ "forceConsistentCasingInFileNames": true,
+ "paths": {
+ "@carbon/type": ["carbon__type"]
+ }
+ },
+ "files": ["index.d.ts", "carbon__type-tests.ts"]
+}
diff --git a/types/carbon__type/tslint.json b/types/carbon__type/tslint.json
new file mode 100644
index 0000000000..3db14f85ea
--- /dev/null
+++ b/types/carbon__type/tslint.json
@@ -0,0 +1 @@
+{ "extends": "dtslint/dt.json" }
diff --git a/types/cassandra-driver/cassandra-driver-tests.ts b/types/cassandra-driver/cassandra-driver-tests.ts
index 3e203837b7..b4f850c315 100644
--- a/types/cassandra-driver/cassandra-driver-tests.ts
+++ b/types/cassandra-driver/cassandra-driver-tests.ts
@@ -102,3 +102,35 @@ const mapper = new cassandra.mapping.Mapper(
const videoMapper = mapper.forModel('Video');
videoMapper.insert({ videoId: 'uuid', addedDate: new Date(), userId: 'uuid', name: 'My video', description: 'My desc' });
videoMapper.find({ videoId: 'uuid' }).then(results => results.first());
+
+console.log(cassandra.version);
+
+const metadata = new cassandra.metadata.Metadata(cassandra.defaultOptions(), undefined);
+let refreshFinished: Promise = metadata.refreshKeyspaces();
+refreshFinished = metadata.refreshKeyspaces(true);
+metadata.refreshKeyspaces(() => {});
+metadata.refreshKeyspaces(true, () => {});
+
+const start: cassandra.token.Token = new cassandra.token.Token("x");
+const end: cassandra.token.Token = new cassandra.token.Token("z");
+
+const tokenizer: cassandra.token.Tokenizer = {
+ hash: (value: Buffer | number[]) => new cassandra.token.Token("x"),
+ parse: (value: string) => new cassandra.token.Token("x"),
+ minToken: () => new cassandra.token.Token("x"),
+ split: (start: cassandra.token.Token, end: cassandra.token.Token, numberOfSplits: number) => [],
+ splitBase: (start: number, end: number, ringEnd: number, ringLength: number, numberOfSplits: number): number[] => [1],
+ stringify: (token: cassandra.token.Token): string => "asd"
+};
+
+const range: cassandra.token.TokenRange = new cassandra.token.TokenRange(start, end, tokenizer);
+
+class MyLoadBalancingPolicy extends cassandra.policies.loadBalancing.LoadBalancingPolicy {
+ getDistance() {
+ return cassandra.types.distance.ignored;
+ }
+}
+
+const myPolicy: cassandra.policies.loadBalancing.LoadBalancingPolicy = new MyLoadBalancingPolicy();
+let existingPolicy: cassandra.policies.loadBalancing.LoadBalancingPolicy = new cassandra.policies.loadBalancing.DCAwareRoundRobinPolicy();
+existingPolicy = new cassandra.policies.loadBalancing.DCAwareRoundRobinPolicy("dc");
diff --git a/types/cassandra-driver/index.d.ts b/types/cassandra-driver/index.d.ts
index 02853c66ba..18527ed8c5 100644
--- a/types/cassandra-driver/index.d.ts
+++ b/types/cassandra-driver/index.d.ts
@@ -34,43 +34,29 @@ export namespace policies {
}
namespace loadBalancing {
- let DCAwareRoundRobinPolicy: DCAwareRoundRobinPolicyStatic;
- let RoundRobinPolicy: RoundRobinPolicyStatic;
- let TokenAwarePolicy: TokenAwarePolicyStatic;
- let WhiteListPolicy: WhiteListPolicyStatic;
-
- interface LoadBalancingPolicy {
+ class LoadBalancingPolicy {
init(client: Client, hosts: HostMap, callback: Callback): void;
getDistance(host: Host): types.distance;
newQueryPlan(keyspace: string, queryOptions: ExecutionOptions | null, callback: Callback): void;
+ getOptions(): Map;
}
- interface DCAwareRoundRobinPolicyStatic {
- new (localDc?: string): DCAwareRoundRobinPolicy;
- }
-
- interface DCAwareRoundRobinPolicy extends LoadBalancingPolicy {
+ class DCAwareRoundRobinPolicy extends LoadBalancingPolicy {
+ localDc: string;
localHostsArray: Host[];
- remoteHostsArray: Host[];
+
+ constructor(localDc?: string);
}
- interface RoundRobinPolicyStatic {
- new (): RoundRobinPolicy;
+ class RoundRobinPolicy extends LoadBalancingPolicy {}
+
+ class TokenAwarePolicy extends LoadBalancingPolicy {
+ constructor(childPolicy: LoadBalancingPolicy);
}
- interface RoundRobinPolicy extends LoadBalancingPolicy { }
-
- interface TokenAwarePolicyStatic {
- new (childPolicy: LoadBalancingPolicy): TokenAwarePolicy;
+ class WhiteListPolicy extends LoadBalancingPolicy {
+ constructor(childPolicy: LoadBalancingPolicy, whiteList: string[]);
}
-
- interface TokenAwarePolicy extends LoadBalancingPolicy { }
-
- interface WhiteListPolicyStatic {
- new (childPolicy: LoadBalancingPolicy, whiteList: string[]): WhiteListPolicy;
- }
-
- interface WhiteListPolicy extends LoadBalancingPolicy { }
}
namespace reconnection {
@@ -499,8 +485,6 @@ export namespace types {
}
export let Client: ClientStatic;
-export let Host: HostStatic;
-export let HostMap: HostMapStatic;
export let Encoder: EncoderStatic;
export interface ClientOptions {
@@ -611,14 +595,10 @@ export interface Client extends events.EventEmitter {
stream(query: string, params?: any, options?: QueryOptions, callback?: Callback): NodeJS.ReadableStream;
}
-export interface HostStatic {
- new (address: string, protocolVersion: number, options: ClientOptions): Host;
-}
-
export interface Host extends events.EventEmitter {
address: string;
cassandraVersion: string;
- dataCenter: string;
+ datacenter: string;
rack: string;
tokens: string[];
@@ -627,10 +607,6 @@ export interface Host extends events.EventEmitter {
isUp(): boolean;
}
-export interface HostMapStatic {
- new (): HostMap;
-}
-
export interface HostMap extends events.EventEmitter {
length: number;
@@ -742,19 +718,10 @@ export namespace errors {
}
export namespace metadata {
- let Aggregate: AggregateStatic;
- let Index: IndexStatic;
- let MaterializedView: MaterializedViewStatic;
let Metadata: MetadataStatic;
- let SchemaFunction: SchemaFunctionStatic;
- let TableMetadata: TableMetadataStatic;
type caching = "all" | "keys_only" | "rows_only" | "none";
- interface AggregateStatic {
- new (): Aggregate;
- }
-
interface Aggregate {
argumentTypes: Array<{ code: number, info: any }>;
finalFunction: string;
@@ -766,10 +733,6 @@ export namespace metadata {
stateType: string;
}
- interface ClientStateStatic {
- new (): ClientState;
- }
-
interface ClientState {
getConnectedHosts(): Host[];
getInFlightQueries(host: Host): number;
@@ -822,13 +785,6 @@ export namespace metadata {
composites
}
- interface IndexStatic {
- new (name: string, target: string, kind: string | IndexType, options: object): Index;
-
- fromRows(indexRows: types.Row[]): Index[];
- fromColumnRows(columnRows: types.Row[], columnsByName: { [key: string]: ColumnInfo }): Index[];
- }
-
interface Index {
kind: IndexType;
name: string;
@@ -840,11 +796,19 @@ export namespace metadata {
isKeysKind(): boolean;
}
- interface MaterializedViewStatic {
- new (name: string): MaterializedView;
+ interface MaterializedView extends DataCollection { }
+
+ interface QueryTrace {
+ requestType: any;
+ coordinator: any;
+ parameters: any;
+ startedAt: any;
+ duration: any;
+ clientAddress: any;
+ events: Array<{ id: any; activity: any; source: any; elapsed: any; thread: any }>;
}
- interface MaterializedView extends DataCollection { }
+ type MetadataCallback = (err: any, retVal: T) => void;
interface MetadataStatic {
new (options: ClientOptions, controlConnection: any): Metadata;
@@ -853,21 +817,34 @@ export namespace metadata {
interface Metadata {
clearPrepared(): void;
- getAggregate(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>, callback: Callback): void;
- getAggregates(keyspaceName: string, name: string, callback: Callback): void;
- getFunction(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>, callback: Callback): void;
- getFunctions(keyspaceName: string, name: string, callback: Callback): void;
- getMaterializedView(keyspaceName: string, name: string, callback: Callback): void;
- getReplicas(keyspaceName: string, tokenBuffer: Buffer): any[];
- getTable(keyspaceName: string, name: string, callback: Callback): void;
- getTrace(traceId: types.Uuid, callback: Callback): void;
- getUdt(keyspaceName: string, name: string, callback: Callback): void;
- refreshKeyspace(name: string, callback?: Callback): void;
- refreshKeyspaces(callback?: Callback): void;
- }
-
- interface SchemaFunctionStatic {
- new (): SchemaFunction;
+ getAggregate(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>, callback: MetadataCallback): void;
+ getAggregate(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>): Promise;
+ getAggregates(keyspaceName: string, name: string, callback: MetadataCallback): void;
+ getAggregates(keyspaceName: string, name: string): Promise;
+ getFunction(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>, callback: MetadataCallback): void;
+ getFunction(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>): Promise;
+ getFunctions(keyspaceName: string, name: string, callback: MetadataCallback): void;
+ getFunctions(keyspaceName: string, name: string): Promise;
+ getMaterializedView(keyspaceName: string, name: string, callback: MetadataCallback): void;
+ getMaterializedView(keyspaceName: string, name: string, callback: Callback): Promise;
+ getReplicas(keyspaceName: string, token: Buffer | token.Token | token.TokenRange): any[]; // TODO
+ getTable(keyspaceName: string, name: string, callback: MetadataCallback): void;
+ getTable(keyspaceName: string, name: string): Promise;
+ getTokenRanges(): Set;
+ getTokenRangesForHost(keyspaceName: string, host: Host): Set | null;
+ getTrace(traceId: types.Uuid, consistency: types.consistencies, callback: MetadataCallback): void;
+ getTrace(traceId: types.Uuid, consistency: types.consistencies, callback: Callback): Promise;
+ getTrace(traceId: types.Uuid, callback: MetadataCallback): void;
+ getTrace(traceId: types.Uuid): Promise;
+ getUdt(keyspaceName: string, name: string, callback: MetadataCallback): void; // TODO
+ getUdt(keyspaceName: string, name: string): Promise; // TODO
+ newToken(components: Buffer[] | Buffer | string): token.Token;
+ newTokenRange(start: token.Token, end: token.Token): token.TokenRange;
+ refreshKeyspace(name: string, callback: Callback): void;
+ refreshKeyspace(name: string): Promise;
+ refreshKeyspaces(waitReconnect: boolean, callback: Callback): void;
+ refreshKeyspaces(waitReconnect?: boolean): Promise;
+ refreshKeyspaces(callback: Callback): void;
}
interface SchemaFunction {
@@ -882,10 +859,6 @@ export namespace metadata {
signature: string[];
}
- interface TableMetadataStatic {
- new (name: string): TableMetadata;
- }
-
interface TableMetadata extends DataCollection {
indexes: Index[];
indexInterval?: number;
@@ -927,6 +900,7 @@ export interface ExecutionOptions {
}
export let ExecutionOptions: ExecutionOptionsStatic;
+export let ExecutionProfile: ExecutionProfileStatic;
export namespace mapping {
let Mapper: MapperStatic;
@@ -1136,3 +1110,41 @@ export namespace metrics {
}
interface DefaultMetrics extends ClientMetrics {}
}
+
+export namespace token {
+ interface Tokenizer {
+ hash(value: Buffer | number[]): Token;
+ parse(value: string): Token;
+ minToken(): Token;
+ split(start: Token, end: Token, numberOfSplits: number): TokenRange[];
+ splitBase(start: number, end: number, ringEnd: number, ringLength: number, numberOfSplits: number): number[];
+ stringify(token: Token): string;
+ }
+
+ class Token {
+ constructor(value: any);
+
+ getType(): { code: number, info: any };
+ getValue(): any;
+ compare(other: Token): number;
+ equals(other: Token): boolean;
+ }
+
+ class TokenRange {
+ start: Token;
+ end: Token;
+
+ constructor(start: Token, end: Token, tokenizer: Tokenizer);
+
+ splitEvenly(numberOfSplits: number): TokenRange[];
+ isEmpty(): boolean;
+ isWrappedAround(): boolean;
+ unwrap(): TokenRange[];
+ contains(token: Token): boolean;
+ equals(other: TokenRange): boolean;
+ compare(other: TokenRange): number;
+ }
+}
+
+export function defaultOptions(): ClientOptions;
+export const version: string;
diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts
index 8e795ed77c..0b78644a96 100644
--- a/types/chart.js/index.d.ts
+++ b/types/chart.js/index.d.ts
@@ -417,6 +417,7 @@ declare namespace Chart {
}
interface ChartLineOptions {
+ cubicInterpolationMode?: 'default' | 'monotone';
tension?: number;
backgroundColor?: ChartColor;
borderWidth?: number;
diff --git a/types/color-support/color-support-tests.ts b/types/color-support/color-support-tests.ts
new file mode 100644
index 0000000000..45bb6317cf
--- /dev/null
+++ b/types/color-support/color-support-tests.ts
@@ -0,0 +1,48 @@
+import colorSupport = require('color-support');
+
+(() => {
+ const result = colorSupport();
+ if (!result) {
+ console.log('color is not supported');
+ } else if (result.has16m) {
+ console.log('\x1b[38;2;102;194;255m16m colors\x1b[0m');
+ } else if (result.has256) {
+ console.log('\x1b[38;5;119m256 colors\x1b[0m');
+ } else if (result.hasBasic) {
+ console.log('\x1b[31mbasic colors\x1b[0m');
+ } else {
+ console.log('Level: ', result.level);
+ console.log('this is impossible, but colors are not supported');
+ }
+})();
+
+(() => {
+ const result = colorSupport({
+ alwaysReturn: false,
+ env: process.env,
+ ignoreCI: true,
+ ignoreDumb: true,
+ ignoreTTY: true,
+ level: 2,
+ stream: process.stdout,
+ term: process.env.TERM,
+ }, {
+ has16m: false,
+ has256: false,
+ hasBasic: false,
+ level: 0,
+ });
+
+ if (!result) {
+ console.log('color is not supported');
+ } else if (result.has16m) {
+ console.log('\x1b[38;2;102;194;255m16m colors\x1b[0m');
+ } else if (result.has256) {
+ console.log('\x1b[38;5;119m256 colors\x1b[0m');
+ } else if (result.hasBasic) {
+ console.log('\x1b[31mbasic colors\x1b[0m');
+ } else {
+ console.log('Level: ', result.level);
+ console.log('this is impossible, but colors are not supported');
+ }
+})();
diff --git a/types/color-support/index.d.ts b/types/color-support/index.d.ts
new file mode 100644
index 0000000000..290a6e29b0
--- /dev/null
+++ b/types/color-support/index.d.ts
@@ -0,0 +1,34 @@
+// Type definitions for color-support 1.1
+// Project: https://github.com/isaacs/color-support#readme
+// Definitions by: Guketlev Dmitry
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// TypeScript Version: 2.2
+
+///
+
+type ColorSupportLevel = 0 | 1 | 2 | 3;
+
+interface ColorSupportOptions {
+ alwaysReturn?: boolean;
+ env?: NodeJS.ProcessEnv;
+ ignoreCI?: boolean;
+ ignoreDumb?: boolean;
+ ignoreTTY?: boolean;
+ level?: ColorSupportLevel;
+ stream?: NodeJS.WriteStream;
+ term?: string;
+}
+
+interface ColorSupportResult {
+ level: ColorSupportLevel;
+ hasBasic: boolean;
+ has256: boolean;
+ has16m: boolean;
+}
+
+type ColorSupport = (options?: ColorSupportOptions,
+ obj?: ColorSupportResult) => false | ColorSupportResult;
+
+declare var colorSupport: ColorSupport;
+
+export = colorSupport;
diff --git a/types/color-support/tsconfig.json b/types/color-support/tsconfig.json
new file mode 100644
index 0000000000..f1e6de8e28
--- /dev/null
+++ b/types/color-support/tsconfig.json
@@ -0,0 +1,23 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "lib": [
+ "es6"
+ ],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": true,
+ "strictFunctionTypes": true,
+ "baseUrl": "../",
+ "typeRoots": [
+ "../"
+ ],
+ "types": [],
+ "noEmit": true,
+ "forceConsistentCasingInFileNames": true
+ },
+ "files": [
+ "index.d.ts",
+ "color-support-tests.ts"
+ ]
+}
diff --git a/types/color-support/tslint.json b/types/color-support/tslint.json
new file mode 100644
index 0000000000..3db14f85ea
--- /dev/null
+++ b/types/color-support/tslint.json
@@ -0,0 +1 @@
+{ "extends": "dtslint/dt.json" }
diff --git a/types/d3-force/d3-force-tests.ts b/types/d3-force/d3-force-tests.ts
index 6b73a1dbf4..9bf424c1b6 100644
--- a/types/d3-force/d3-force-tests.ts
+++ b/types/d3-force/d3-force-tests.ts
@@ -685,6 +685,7 @@ nodeLinkSimulation = nodeLinkSimulation.stop();
// tick() -----------------------------------------------------------------------------
nodeLinkSimulation.tick();
+nodeLinkSimulation.tick(10);
// find() -----------------------------------------------------------------------------
diff --git a/types/d3-force/index.d.ts b/types/d3-force/index.d.ts
index 35f4d06657..563ca925c3 100644
--- a/types/d3-force/index.d.ts
+++ b/types/d3-force/index.d.ts
@@ -1,9 +1,12 @@
-// Type definitions for D3JS d3-force module 1.1
+// Type definitions for D3JS d3-force module 1.2
// Project: https://github.com/d3/d3-force/
-// Definitions by: Tom Wanzek , Alex Ford , Boris Yankov
+// Definitions by: Tom Wanzek
+// Alex Ford
+// Boris Yankov
+// denisname
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-// Last module patch version validated against: 1.1.0
+// Last module patch version validated against: 1.2.0
// -----------------------------------------------------------------------
// Force Simulation
@@ -108,13 +111,16 @@ export interface Simulation name.test("DefinitelyTyped:log")));
+log("Enabled?: %s", debug1.enabled("DefinitelyTyped:log"));
+log("Name Enabled: %s", debug1.names.some(name => name.test("DefinitelyTyped:log")));
log("Namespace: %s", log.namespace);
-var error:debug.IDebugger = debug("DefinitelyTyped:error");
+const error: debug1.Debugger = debug1("DefinitelyTyped:error");
error.log = console.error.bind(console);
error("This should be printed to stderr");
-var extendedLog: debug.IDebugger = log.extend('extended');
+const extendedLog: debug1.Debugger = log.extend('extended');
extendedLog("Testing this is also an IDebugger.");
-var extendedWithCustomDelimiter: debug.IDebugger = log.extend('with-delim', '.');
-extendedWithCustomDelimiter("Testing this is an IDebugger, too.");
\ No newline at end of file
+const extendedWithCustomDelimiter: debug1.Debugger = log.extend('with-delim', '.');
+extendedWithCustomDelimiter("Testing this is an IDebugger, too.");
diff --git a/types/debug/index.d.ts b/types/debug/index.d.ts
index 2eca1c8fb8..2067b27222 100644
--- a/types/debug/index.d.ts
+++ b/types/debug/index.d.ts
@@ -1,40 +1,45 @@
-// Type definitions for debug
+// Type definitions for debug 4.1
// Project: https://github.com/visionmedia/debug
// Definitions by: Seon-Wook Park
// Gal Talmor
// John McLaughlin
// Brasten Sager
+// Nicolas Penin
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-declare var debug: debug.IDebug;
+declare var debug: debug.Debug & {debug: debug.Debug, default: debug.Debug};
export = debug;
export as namespace debug;
declare namespace debug {
- export interface IDebug {
- (namespace: string): debug.IDebugger,
- coerce: (val: any) => any,
- disable: () => void,
- enable: (namespaces: string) => void,
- enabled: (namespaces: string) => boolean,
+ interface Debug {
+ (namespace: string): Debugger;
+ coerce: (val: any) => any;
+ disable: () => void;
+ enable: (namespaces: string) => void;
+ enabled: (namespaces: string) => boolean;
- names: RegExp[],
- skips: RegExp[],
+ names: RegExp[];
+ skips: RegExp[];
- formatters: IFormatters
+ formatters: Formatters;
}
- export interface IFormatters {
- [formatter: string]: Function
+ type IDebug = Debug;
+
+ interface Formatters {
+ [formatter: string]: (v: any) => string;
}
- export interface IDebugger {
+ type IDebugger = Debugger;
+
+ interface Debugger {
(formatter: any, ...args: any[]): void;
enabled: boolean;
- log: Function;
+ log: (v: any) => string;
namespace: string;
- extend: (namespace: string, delimiter?: string) => debug.IDebugger;
+ extend: (namespace: string, delimiter?: string) => Debugger;
}
}
diff --git a/types/debug/tslint.json b/types/debug/tslint.json
index a41bf5d19a..f93cf8562a 100644
--- a/types/debug/tslint.json
+++ b/types/debug/tslint.json
@@ -1,79 +1,3 @@
{
- "extends": "dtslint/dt.json",
- "rules": {
- "adjacent-overload-signatures": false,
- "array-type": false,
- "arrow-return-shorthand": false,
- "ban-types": false,
- "callable-types": false,
- "comment-format": false,
- "dt-header": false,
- "eofline": false,
- "export-just-namespace": false,
- "import-spacing": false,
- "interface-name": false,
- "interface-over-type-literal": false,
- "jsdoc-format": false,
- "max-line-length": false,
- "member-access": false,
- "new-parens": false,
- "no-any-union": false,
- "no-boolean-literal-compare": false,
- "no-conditional-assignment": false,
- "no-consecutive-blank-lines": false,
- "no-construct": false,
- "no-declare-current-package": false,
- "no-duplicate-imports": false,
- "no-duplicate-variable": false,
- "no-empty-interface": false,
- "no-for-in-array": false,
- "no-inferrable-types": false,
- "no-internal-module": false,
- "no-irregular-whitespace": false,
- "no-mergeable-namespace": false,
- "no-misused-new": false,
- "no-namespace": false,
- "no-object-literal-type-assertion": false,
- "no-padding": false,
- "no-redundant-jsdoc": false,
- "no-redundant-jsdoc-2": false,
- "no-redundant-undefined": false,
- "no-reference-import": false,
- "no-relative-import-in-test": false,
- "no-self-import": false,
- "no-single-declare-module": false,
- "no-string-throw": false,
- "no-unnecessary-callback-wrapper": false,
- "no-unnecessary-class": false,
- "no-unnecessary-generics": false,
- "no-unnecessary-qualifier": false,
- "no-unnecessary-type-assertion": false,
- "no-useless-files": false,
- "no-var-keyword": false,
- "no-var-requires": false,
- "no-void-expression": false,
- "no-trailing-whitespace": false,
- "object-literal-key-quotes": false,
- "object-literal-shorthand": false,
- "one-line": false,
- "one-variable-per-declaration": false,
- "only-arrow-functions": false,
- "prefer-conditional-expression": false,
- "prefer-const": false,
- "prefer-declare-function": false,
- "prefer-for-of": false,
- "prefer-method-signature": false,
- "prefer-template": false,
- "radix": false,
- "semicolon": false,
- "space-before-function-paren": false,
- "space-within-parens": false,
- "strict-export-declare-modifiers": false,
- "trim-file": false,
- "triple-equals": false,
- "typedef-whitespace": false,
- "unified-signatures": false,
- "void-return": false,
- "whitespace": false
- }
+ "extends": "dtslint/dt.json"
}
diff --git a/types/elliptic/index.d.ts b/types/elliptic/index.d.ts
index fa8e19a2cf..722568a6f6 100644
--- a/types/elliptic/index.d.ts
+++ b/types/elliptic/index.d.ts
@@ -176,7 +176,7 @@ export class ec {
keyPair(options: ec.KeyPairOptions): ec.KeyPair;
keyFromPrivate(priv: Buffer | string | ec.KeyPair, enc?: string): ec.KeyPair;
- keyFromPublic(pub: Buffer | string | ec.KeyPair, enc?: string): ec.KeyPair;
+ keyFromPublic(pub: Buffer | string | {x: string, y: string} | ec.KeyPair, enc?: string): ec.KeyPair;
genKeyPair(options?: ec.GenKeyPairOptions): ec.KeyPair;
sign(msg: BNInput, key: Buffer | ec.KeyPair, enc: string, options?: ec.SignOptions): ec.Signature;
sign(msg: BNInput, key: Buffer | ec.KeyPair, options?: ec.SignOptions): ec.Signature;
@@ -201,7 +201,7 @@ export namespace ec {
}
class KeyPair {
- static fromPublic(ec: ec, pub: Buffer | string | KeyPair, enc?: string): KeyPair;
+ static fromPublic(ec: ec, pub: Buffer | string | {x: string, y: string} | KeyPair, enc?: string): KeyPair;
static fromPrivate(ec: ec, priv: Buffer | string | KeyPair, enc?: string): KeyPair;
ec: ec;
diff --git a/types/enzyme/index.d.ts b/types/enzyme/index.d.ts
index 58e5938a8f..d9f858d2a7 100644
--- a/types/enzyme/index.d.ts
+++ b/types/enzyme/index.d.ts
@@ -619,7 +619,7 @@ export class EnzymeAdapter {
}
/**
- * Configure enzyme to use the correct adapter for the react verstion
+ * Configure enzyme to use the correct adapter for the react version
* This is enabling the Enzyme configuration with adapters in TS
*/
export function configure(options: {
diff --git a/types/express-winston/express-winston-tests.ts b/types/express-winston/express-winston-tests.ts
index f370abdb5d..5d48bdd897 100644
--- a/types/express-winston/express-winston-tests.ts
+++ b/types/express-winston/express-winston-tests.ts
@@ -18,7 +18,7 @@ app.use(expressWinston.logger({
meta: true,
metaField: 'metaField',
msg: 'msg',
- requestFilter: (req, prop) => true,
+ requestFilter: (req, prop) => req[prop],
requestWhitelist: ['foo', 'bar'],
skip: (req, res) => false,
statusLevels: ({ error: 'error', success: 'success', warn: 'warn' }),
@@ -69,8 +69,8 @@ app.use(expressWinston.errorLogger({
expressWinston.bodyBlacklist.push('potato');
expressWinston.bodyWhitelist.push('apple');
-expressWinston.defaultRequestFilter = (req: express.Request, prop: string) => true;
-expressWinston.defaultResponseFilter = (res: express.Response, prop: string) => true;
+expressWinston.defaultRequestFilter = (req: expressWinston.FilterRequest, prop: string) => req[prop];
+expressWinston.defaultResponseFilter = (res: expressWinston.FilterResponse, prop: string) => res[prop];
expressWinston.defaultSkip = () => true;
expressWinston.ignoredRoutes.push('/ignored');
expressWinston.responseWhitelist.push('body');
diff --git a/types/express-winston/index.d.ts b/types/express-winston/index.d.ts
index 462f3df1b3..f7ae04319b 100644
--- a/types/express-winston/index.d.ts
+++ b/types/express-winston/index.d.ts
@@ -8,10 +8,18 @@ import { ErrorRequestHandler, Handler, Request, Response } from 'express';
import * as winston from 'winston';
import * as Transport from 'winston-transport';
+export interface FilterRequest extends Request {
+ [other: string]: any;
+}
+
+export interface FilterResponse extends Response {
+ [other: string]: any;
+}
+
export type DynamicMetaFunction = (req: Request, res: Response, err: Error) => object;
export type DynamicLevelFunction = (req: Request, res: Response, err: Error) => string;
-export type RequestFilter = (req: Request, propName: string) => boolean;
-export type ResponseFilter = (res: Response, propName: string) => boolean;
+export type RequestFilter = (req: FilterRequest, propName: string) => any;
+export type ResponseFilter = (res: FilterResponse, propName: string) => any;
export type RouteFilter = (req: Request, res: Response) => boolean;
export interface BaseLoggerOptions {
diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts
index 68c0a73efe..5cc59d0941 100644
--- a/types/fabric/fabric-impl.d.ts
+++ b/types/fabric/fabric-impl.d.ts
@@ -3774,7 +3774,18 @@ interface IAllFilters {
*/
fromObject(object: any): IBrightnessFilter
};
- Convolute: {
+ ColorMatrix: {
+ new(options?: {
+ /** Filter matrix */
+ matrix?: number[]
+ }): IColorMatrix;
+ /**
+ * Returns filter instance from an object representation
+ * @param object Object to create an instance from
+ */
+ fromObject(object: any): IColorMatrix
+ };
+ Convolute: {
new(options?: {
opaque?: boolean,
/** Filter matrix */
@@ -3962,6 +3973,13 @@ interface IBrightnessFilter extends IBaseFilter {
*/
applyTo(canvasEl: HTMLCanvasElement): void;
}
+interface IColorMatrix extends IBaseFilter {
+ /**
+ * Applies filter to canvas element
+ * @param canvasEl Canvas element to apply filter to
+ */
+ applyTo(canvasEl: HTMLCanvasElement): void;
+}
interface IConvoluteFilter extends IBaseFilter {
/**
* Applies filter to canvas element
diff --git a/types/fastify-cors/fastify-cors-tests.ts b/types/fastify-cors/fastify-cors-tests.ts
deleted file mode 100644
index 5fcd7e20d4..0000000000
--- a/types/fastify-cors/fastify-cors-tests.ts
+++ /dev/null
@@ -1,89 +0,0 @@
-import fastifyCors = require("fastify-cors");
-
-fastifyCors();
-
-const fastifyCorsOptions: fastifyCors.FastifyCorsOptions = {
- origin: true,
- allowedHeaders: "authorization,content-type",
- methods: "GET,POST,PUT,PATCH,DELETE,OPTIONS",
- credentials: true,
- exposedHeaders: "authorization",
- maxAge: 13000,
- preflightContinue: false,
- optionsSuccessStatus: 200,
- preflight: false,
-};
-
-const fastifyCorsOptionsArray: fastifyCors.FastifyCorsOptions = {
- origin: true,
- allowedHeaders: ["authorization", "content-type"],
- methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
- credentials: true,
- exposedHeaders: ["authorization"],
- maxAge: 13000,
- preflightContinue: false,
- optionsSuccessStatus: 200,
- preflight: false,
-};
-
-const originString: fastifyCors.FastifyCorsOptions = {
- origin: "*",
- allowedHeaders: ["authorization", "content-type"],
- methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
- credentials: true,
- exposedHeaders: ["authorization"],
- maxAge: 13000,
- preflightContinue: false,
- optionsSuccessStatus: 200,
- preflight: false,
-};
-
-const originRegexp: fastifyCors.FastifyCorsOptions = {
- origin: /\*/,
- allowedHeaders: ["authorization", "content-type"],
- methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
- credentials: true,
- exposedHeaders: ["authorization"],
- maxAge: 13000,
- preflightContinue: false,
- optionsSuccessStatus: 200,
- preflight: false,
-};
-
-const originStringArray: fastifyCors.FastifyCorsOptions = {
- origin: ["*", "something"],
- allowedHeaders: ["authorization", "content-type"],
- methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
- credentials: true,
- exposedHeaders: ["authorization"],
- maxAge: 13000,
- preflightContinue: false,
- optionsSuccessStatus: 200,
- preflight: false,
-};
-
-const originRegexpArray: fastifyCors.FastifyCorsOptions = {
- origin: [/\*/, /something/],
- allowedHeaders: ["authorization", "content-type"],
- methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
- credentials: true,
- exposedHeaders: ["authorization"],
- maxAge: 13000,
- preflightContinue: false,
- optionsSuccessStatus: 200,
- preflight: false,
-};
-
-const originCallback: fastifyCors.FastifyCorsOptions = {
- origin: (err: Error, allow: boolean) => {
- throw err;
- },
- allowedHeaders: ["authorization", "content-type"],
- methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
- credentials: true,
- exposedHeaders: ["authorization"],
- maxAge: 13000,
- preflightContinue: false,
- optionsSuccessStatus: 200,
- preflight: false,
-};
diff --git a/types/fastify-cors/index.d.ts b/types/fastify-cors/index.d.ts
deleted file mode 100644
index 907689a72c..0000000000
--- a/types/fastify-cors/index.d.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-// Type definitions for fastify-cors 0.1
-// Project: https://github.com/fastify/fastify-cors#readme
-// Definitions by: Jannik Keye
-// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-
-type originCallback = (err: Error, allow: boolean) => void;
-
-/**
- * fastify-cors enables the use of CORS in a Fastify application.
- */
-declare function fastifyCors(): void;
-
-declare namespace fastifyCors {
- /**
- * Options for configuring the fastify-cors plugin.
- */
- interface FastifyCorsOptions {
- /**
- * Configures the Access-Control-Allow-Origin CORS header.
- */
- origin?: string | boolean | RegExp | string[] | RegExp[] | originCallback;
- /**
- * Configures the Access-Control-Allow-Credentials CORS header.
- * Set to true to pass the header, otherwise it is omitted.
- */
- credentials?: boolean;
- /**
- * Configures the Access-Control-Expose-Headers CORS header.
- * Expects a comma-delimited string (ex: 'Content-Range,X-Content-Range')
- * or an array (ex: ['Content-Range', 'X-Content-Range']).
- * If not specified, no custom headers are exposed.
- */
- exposedHeaders?: string | string[];
- /**
- * Configures the Access-Control-Allow-Headers CORS header.
- * Expects a comma-delimited string (ex: 'Content-Type,Authorization')
- * or an array (ex: ['Content-Type', 'Authorization']). If not
- * specified, defaults to reflecting the headers specified in the
- * request's Access-Control-Request-Headers header.
- */
- allowedHeaders?: string | string[];
- /**
- * Configures the Access-Control-Allow-Methods CORS header.
- * Expects a comma-delimited string (ex: 'GET,PUT,POST') or an array (ex: ['GET', 'PUT', 'POST']).
- */
- methods?: string | string[];
- /**
- * Configures the Access-Control-Max-Age CORS header.
- * Set to an integer to pass the header, otherwise it is omitted.
- */
- maxAge?: number;
- /**
- * Pass the CORS preflight response to the route handler (default: false).
- */
- preflightContinue?: boolean;
- /**
- * Provides a status code to use for successful OPTIONS requests,
- * since some legacy browsers (IE11, various SmartTVs) choke on 204.
- */
- optionsSuccessStatus?: number;
- /**
- * Pass the CORS preflight response to the route handler (default: false).
- */
- preflight?: boolean;
- }
-}
-
-export = fastifyCors;
diff --git a/types/fastify-static/fastify-static-tests.ts b/types/fastify-static/fastify-static-tests.ts
deleted file mode 100644
index 630fc0ef52..0000000000
--- a/types/fastify-static/fastify-static-tests.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import path = require("path");
-import fastify = require("fastify");
-import fastifyStatic = require("fastify-static");
-
-const app = fastify();
-
-app.register(fastifyStatic, {
- root: path.join(__dirname, "public"),
- prefix: "/public/", // optional: default '/'
- immutable: true,
- maxAge: 42
-});
-
-app.get("/another/path", (req, reply) => {
- reply.sendFile("myHtml.html"); // serving path.join(__dirname, 'public', 'myHtml.html') directly
-});
diff --git a/types/fastify-static/index.d.ts b/types/fastify-static/index.d.ts
deleted file mode 100644
index ef4eda1952..0000000000
--- a/types/fastify-static/index.d.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-// Type definitions for fastify-static 0.14
-// Project: https://github.com/fastify/fastify-static
-// Definitions by: Leonhard Melzer
-// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-// TypeScript Version: 2.4
-
-import fastify = require("fastify");
-
-import { Server, IncomingMessage, ServerResponse } from "http";
-
-declare module "fastify" {
- interface FastifyReply {
- sendFile(filename: string): FastifyReply;
- }
-}
-
-declare function fastifyStatic(): void;
-
-declare namespace fastifyStatic {
- interface FastifyStaticOptions {
- root: string;
- prefix?: string;
- serve?: boolean;
- decorateReply?: boolean;
- schemaHide?: boolean;
- setHeaders?: () => void;
-
- // Passed on to `send`
- acceptRanges?: boolean;
- cacheControl?: boolean;
- dotfiles?: boolean;
- etag?: boolean;
- extensions?: string[];
- immutable?: boolean;
- index?: string[];
- lastModified?: boolean;
- maxAge?: string | number;
- }
-}
-
-export = fastifyStatic;
diff --git a/types/feathersjs__errors/index.d.ts b/types/feathersjs__errors/index.d.ts
index 056acff676..3994e2056c 100644
--- a/types/feathersjs__errors/index.d.ts
+++ b/types/feathersjs__errors/index.d.ts
@@ -1,11 +1,26 @@
-// Type definitions for @feathersjs/errors 3.2
+// Type definitions for @feathersjs/errors 3.3
// Project: http://feathersjs.com/
// Definitions by: Jan Lohage
+// RazzM13
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
// TypeScript Version: 2.2
+export interface FeathersErrorJSON {
+ readonly name: string;
+ readonly message: string;
+ readonly code: number;
+ readonly className: string;
+ readonly data: any;
+ readonly errors: any;
+}
+
export class FeathersError extends Error {
- constructor(msg: string | Error, name: string, code: number, className: string, data: any)
+ readonly code: number;
+ readonly className: string;
+ readonly data: any;
+ readonly errors: any;
+ constructor(msg: string | Error, name: string, code: number, className: string, data: any);
+ toJSON(): FeathersErrorJSON;
}
export class BadRequest extends FeathersError {
diff --git a/types/generic-pool/generic-pool-tests.ts b/types/generic-pool/generic-pool-tests.ts
index 28590def30..09a46ccf84 100644
--- a/types/generic-pool/generic-pool-tests.ts
+++ b/types/generic-pool/generic-pool-tests.ts
@@ -29,6 +29,7 @@ const opts = {
min: 2,
maxWaitingClients: 2,
testOnBorrow: true,
+ testOnReturn: true,
acquireTimeoutMillis: 100,
fifo: true,
priorityRange: 5,
diff --git a/types/generic-pool/index.d.ts b/types/generic-pool/index.d.ts
index 6bb537e9ba..14fea9497f 100644
--- a/types/generic-pool/index.d.ts
+++ b/types/generic-pool/index.d.ts
@@ -38,6 +38,7 @@ export interface Options {
min?: number;
maxWaitingClients?: number;
testOnBorrow?: boolean;
+ testOnReturn?: boolean;
acquireTimeoutMillis?: number;
fifo?: boolean;
priorityRange?: number;
diff --git a/types/giphy-api/giphy-api-tests.ts b/types/giphy-api/giphy-api-tests.ts
new file mode 100644
index 0000000000..6168ece7ac
--- /dev/null
+++ b/types/giphy-api/giphy-api-tests.ts
@@ -0,0 +1,34 @@
+import giphyApi = require('giphy-api');
+
+const cb = (err: Error, res: any) => {};
+
+giphyApi('API KEY HERE');
+giphyApi({ https: true });
+giphyApi({ timeout: 60 });
+giphyApi({ apiKey: 'API KEY' });
+
+const giphy = giphyApi();
+giphy.search('pokemon', cb);
+giphy.search('pokemon').then(res => {});
+giphy.search({ q: 'pokemon', rating: 'g' }, cb);
+giphy.search({ q: 'pokemon', rating: 'g' }).then(res => {});
+
+giphy.id('feqkVgjJpYtjy', cb);
+giphy.id('feqkVgjJpYtjy').then(res => {});
+giphy.id(['feqkVgjJpYtjy'], cb);
+giphy.id(['feqkVgjJpYtjy']).then(res => {});
+
+giphy.translate('superman', cb);
+giphy.translate('superman').then(res => {});
+giphy.translate({ s: 'superman', rating: 'g', fmt: 'html' }, cb);
+giphy.translate({ s: 'superman', rating: 'g' }).then(res => {});
+
+giphy.random('superman', cb);
+giphy.random('superman').then(res => {});
+giphy.random({ tag: 'superman', rating: 'g' }, cb);
+giphy.random({ tag: 'superman', rating: 'g' }).then(res => {});
+
+giphy.trending(cb);
+giphy.trending().then(res => {});
+giphy.trending({ limit: 2, rating: 'g' });
+giphy.trending({ limit: 2, rating: 'g' }).then(res => {});
diff --git a/types/giphy-api/index.d.ts b/types/giphy-api/index.d.ts
new file mode 100644
index 0000000000..f6174543eb
--- /dev/null
+++ b/types/giphy-api/index.d.ts
@@ -0,0 +1,177 @@
+// Type definitions for giphy-api 2.0
+// Project: https://github.com/austinkelleher/giphy-api
+// Definitions by: Christian Rackerseder
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// TypeScript Version: 2.8
+
+type Rating = "y" | "g" | "pg" | "pg-13" | "r";
+type Format = "html" | "json";
+
+interface GiphyOptions {
+ https?: boolean;
+ timeout?: number;
+ apiKey?: string;
+}
+
+interface BaseOptions {
+ rating: Rating;
+ fmt?: Format;
+}
+
+interface SearchOptions extends BaseOptions {
+ q: string;
+ limit?: number;
+ offset?: number;
+}
+
+interface TranslateOptions extends BaseOptions {
+ s: string;
+}
+
+interface RandomOptions extends BaseOptions {
+ tag: string;
+}
+
+interface TrendingOptions extends BaseOptions {
+ limit?: number;
+}
+
+interface BaseImage {
+ url: string;
+ width: string;
+ height: string;
+}
+
+interface Result {
+ data: [
+ {
+ type: string;
+ id: string;
+ slug: string;
+ url: string;
+ bitly_url: string;
+ embed_url: string;
+ username: string;
+ source: string;
+ rating: Rating;
+ content_url: string;
+ user?: {
+ avatar_url: string;
+ banner_url: string;
+ profile_url: string;
+ username: string;
+ display_name: string;
+ twitter: string;
+ },
+ source_tld: string;
+ source_post_url: string;
+ update_datetime: string;
+ create_datetime: string;
+ import_datetime: string;
+ trending_datetime: string;
+ title: string;
+ images: {
+ fixed_height: BaseImage & {
+ size: string;
+ mp4: string;
+ mp4_size: string;
+ webp: string;
+ webp_size: string;
+ };
+ fixed_height_still: BaseImage;
+ fixed_height_downsampled: BaseImage & {
+ size: string;
+ webp: string;
+ webp_size: string;
+ };
+ fixed_width: BaseImage & {
+ size: string;
+ mp4: string;
+ mp4_size: string;
+ webp: string;
+ webp_size: string;
+ };
+ original_still: BaseImage;
+ fixed_width_still: BaseImage;
+ fixed_width_downsampled: BaseImage & {
+ size: string;
+ webp: string;
+ webp_size: string;
+ };
+ fixed_height_small: BaseImage & {
+ size: string;
+ mp4: string;
+ mp4_size: string;
+ webp: string;
+ webp_size: string;
+ };
+ fixed_height_small_still: BaseImage;
+ fixed_width_small: BaseImage & {
+ size: string;
+ mp4: string;
+ mp4_size: string;
+ webp: string;
+ webp_size: string;
+ };
+ fixed_width_small_still: BaseImage;
+ downsized: BaseImage & {
+ size: string;
+ };
+ downsized_still: BaseImage;
+ downsized_large: BaseImage & {
+ size: string;
+ };
+ downsized_medium: BaseImage & {
+ size: string;
+ };
+ downsized_small: BaseImage & {
+ size: string;
+ };
+ original: BaseImage & {
+ size: string;
+ frames: string;
+ mp4: string;
+ mp4_size: string;
+ webp: string;
+ webp_size: string;
+ };
+ looping: { mp4: string; };
+ preview: {
+ width: string;
+ height: string;
+ mp4: string;
+ mp4_size: string;
+ };
+ preview_gif: BaseImage & {
+ size: string;
+ };
+ };
+ }
+ ];
+ pagination: { total_count: number; count: number; offset: number };
+ meta: {
+ status: number;
+ msg: string;
+ response_id: string;
+ };
+}
+
+type Callback = (err: Error, res: Result) => void;
+
+interface Giphy {
+ search(queryOrOptions: string | SearchOptions, cb: Callback): void;
+ search(queryOrOptions: string | SearchOptions): Promise;
+ id(ids: string | string[], cb: Callback): void;
+ id(ids: string | string[]): Promise;
+ translate(termOrOptions: string | TranslateOptions, cb: Callback): void;
+ translate(termOrOptions: string | TranslateOptions): Promise;
+ random(tagOrOptions: string | RandomOptions, cb: Callback): void;
+ random(tagOrOptions: string | RandomOptions): Promise;
+ trending(options: TrendingOptions, cb: Callback): void;
+ trending(cb: Callback): void;
+ trending(options?: TrendingOptions): Promise;
+}
+
+declare function giphyApi(apiKeyOrOptions?: string | GiphyOptions): Giphy;
+
+export = giphyApi;
diff --git a/types/giphy-api/tsconfig.json b/types/giphy-api/tsconfig.json
new file mode 100644
index 0000000000..e8d707c5fb
--- /dev/null
+++ b/types/giphy-api/tsconfig.json
@@ -0,0 +1,23 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "lib": [
+ "es6"
+ ],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": true,
+ "strictFunctionTypes": true,
+ "baseUrl": "../",
+ "typeRoots": [
+ "../"
+ ],
+ "types": [],
+ "noEmit": true,
+ "forceConsistentCasingInFileNames": true
+ },
+ "files": [
+ "index.d.ts",
+ "giphy-api-tests.ts"
+ ]
+}
diff --git a/types/giphy-api/tslint.json b/types/giphy-api/tslint.json
new file mode 100644
index 0000000000..3db14f85ea
--- /dev/null
+++ b/types/giphy-api/tslint.json
@@ -0,0 +1 @@
+{ "extends": "dtslint/dt.json" }
diff --git a/types/hexo/hexo-tests.ts b/types/hexo/hexo-tests.ts
new file mode 100644
index 0000000000..3c00489c3a
--- /dev/null
+++ b/types/hexo/hexo-tests.ts
@@ -0,0 +1,462 @@
+import Hexo = require('hexo');
+import fs = require('fs');
+import Bunyan = require('bunyan');
+import { ParsedArgs } from 'minimist';
+import util = require('hexo-util');
+import http = require('http');
+
+const config: Hexo.InstanceOptions = {};
+config.debug = false;
+config.safe = false;
+config.silent = false;
+config.config = '_config.yml';
+
+let h: Hexo;
+h = hexo;
+h = new Hexo();
+h = new Hexo('./');
+h = new Hexo('./', config);
+
+const logger: Bunyan = h.log;
+console.log(h.base_dir);
+console.log(h.public_dir);
+console.log(h.source_dir);
+console.log(h.plugin_dir);
+console.log(h.script_dir);
+console.log(h.scaffold_dir);
+console.log(h.theme_dir);
+console.log(h.theme_script_dir);
+console.log(h.config_path);
+console.log(h.env.args);
+console.log(h.env.debug);
+console.log(h.env.safe);
+console.log(h.env.silent);
+console.log(h.env.env);
+console.log(h.env.version);
+console.log(h.env.init);
+console.log(h.config.title);
+console.log(h.config.subtitle);
+console.log(h.config.description);
+console.log(h.config.author);
+console.log(h.config.language);
+console.log(h.config.timezone);
+console.log(h.config.url);
+console.log(h.config.root);
+console.log(h.config.permalink);
+console.log(h.config.permalink_defaults);
+console.log(h.config.source_dir);
+console.log(h.config.public_dir);
+console.log(h.config.tag_dir);
+console.log(h.config.archive_dir);
+console.log(h.config.category_dir);
+console.log(h.config.code_dir);
+console.log(h.config.i18n_dir);
+console.log(h.config.skip_render);
+console.log(h.config.new_post_name);
+console.log(h.config.default_layout);
+console.log(h.config.titlecase);
+console.log(h.config.external_link);
+console.log(h.config.filename_case);
+console.log(h.config.render_drafts);
+console.log(h.config.post_asset_folder);
+console.log(h.config.relative_link);
+console.log(h.config.future);
+console.log(h.config.highlight.enable);
+console.log(h.config.highlight.line_number);
+console.log(h.config.highlight.auto_detect);
+console.log(h.config.highlight.tab_replace);
+console.log(h.config.default_category);
+console.log(h.config.category_map);
+console.log(h.config.tag_map);
+console.log(h.config.time_format);
+console.log(h.config.per_page);
+console.log(h.config.pagination_dir);
+console.log(h.config.theme);
+console.log(h.config.theme_config);
+console.log(h.config.deploy);
+console.log(h.config.include);
+console.log(h.config.exclude);
+console.log(h.config.ignore);
+
+h.init().then(async () => {
+ await h.watch();
+ h.unwatch();
+
+ await h.theme.watch();
+ h.theme.unwatch();
+
+ await h.source.watch();
+ h.source.unwatch();
+
+ await h.load();
+ h.call('config', {_: ['arg1']}, (err, value) => {});
+
+ await h.exit();
+});
+
+h.on('ready', () => {
+ h.on('deployBefore', () => {});
+ h.on('deployAfter', () => {});
+ h.on('exit', err => {
+ console.log(err);
+ });
+ h.on('generateBefore', () => {});
+ h.on('generateAfter', () => {});
+ h.on('new', param => {
+ const path: string = param.path;
+ const content: string = param.content;
+ });
+ h.on('processBefore', (type, path) => {
+ const t: Hexo.Box.File['type'] = type;
+ const p: string = path;
+ });
+ h.on('processAfter', (type, path) => {
+ const t: Hexo.Box.File['type'] = type;
+ const p: string = path;
+ });
+ h.on('ready', () => {});
+
+ {
+ let local: Hexo.Locals.Post[] = [];
+ const model = hexo.locals.get('posts');
+
+ local = model.toArray();
+ const count: number = model.count();
+ model.filter(v => true);
+ model.forEach(v => {});
+ model.map(v => v.name);
+ }
+
+ {
+ let local: Hexo.Locals.Page[] = [];
+ const model = hexo.locals.get('pages');
+
+ local = model.toArray();
+ const count: number = model.count();
+ model.filter(v => true);
+ model.forEach(v => {});
+ model.map(v => v.name);
+ }
+
+ {
+ let local: Hexo.Locals.Category[] = [];
+ const model = hexo.locals.get('categories');
+
+ local = model.toArray();
+ const count: number = model.count();
+ model.filter(v => true);
+ model.forEach(v => {});
+ model.map(v => v.name);
+ }
+
+ {
+ let local: Hexo.Locals.Tag[] = [];
+ const model = hexo.locals.get('tags');
+
+ local = model.toArray();
+ const count: number = model.count();
+ model.filter(v => true);
+ model.forEach(v => {});
+ model.map(v => v.name);
+ }
+
+ {
+ h.locals.set('some-data', () => 'some vlue');
+ h.locals.remove('some-data');
+ h.locals.toObject();
+ h.locals.invalidate();
+ }
+
+ {
+ const route = h.route.get('index.html');
+ if (route) {
+ console.log(route.modified);
+ console.log(route.read());
+ }
+
+ const data: Hexo.Router.Data = {
+ data: 'some data',
+ modified: true,
+ };
+ data.data = new Buffer([]);
+ data.data = () => 'return';
+
+ let router: Hexo.Router;
+ router = h.route;
+ router = h.route.set('index.html', 'content');
+ router = h.route.set('index.html', new Buffer([]));
+ router = h.route.set('index.html', new util.Pattern(() => false));
+ router = h.route.set('index.html', { data: 'index', modified: false });
+
+ router = h.route.remove('index.html');
+
+ const list: string[] = h.route.list();
+ const format: string = h.route.format('/');
+ }
+
+ {
+ h.source.process(() => {});
+ h.source.addProcessor('path', file => {
+ console.log(file.source);
+ console.log(file.path);
+ console.log(file.type);
+ console.log(file.params);
+
+ file.read((err, content) => {
+ console.log(err, content.toString());
+ console.log(content);
+ });
+
+ file.read({encoding: 'utf8', flag: 'r'}, (err, content) => {
+ console.log(err, content.toString());
+ console.log(content);
+ });
+
+ file.readSync({encoding: 'utf8', flag: 'r'});
+
+ file.stat((err, stat) => {
+ console.log(err);
+ console.log(stat.mtime);
+ console.log(stat.ctime);
+ console.log(stat.atime);
+ });
+
+ file.stat().then(stat => {
+ console.log(stat.mtime);
+ console.log(stat.ctime);
+ console.log(stat.atime);
+ });
+
+ const stat: fs.Stats = file.statSync();
+
+ let render = '';
+ file.render({}, (err, result) => {
+ render = result;
+ });
+ file.render((err, result) => {
+ render = result;
+ });
+ file.render().then(result => {
+ render = result;
+ });
+ render = file.renderSync();
+ });
+ }
+
+ {
+ let _bool = true;
+ _bool = h.render.isRenderable('path');
+ _bool = h.render.isRenderableSync('path');
+
+ const option: Hexo.Render.Data = {
+ engine: 'ejs',
+ text: 'test',
+ path: __filename,
+ };
+
+ let _string = '';
+ h.render.render({text: 'example', engine: 'swig'}).then(result => {
+ _string = result;
+ });
+ h.render.render({path: __filename}).then(result => {
+ _string = result;
+ });
+ h.render.render({text: ''}, {foo: 'foo'}).then(result => {
+ _string = result;
+ });
+ _string = h.render.renderSync({text: 'example'});
+
+ _string = h.render.getOutput('ejs');
+ }
+
+ {
+ const data: Hexo.Post.Data = {};
+ data.title = 'Title';
+ data.slug = 'URL';
+ data.layout = 'layout_name';
+ data.path = 'path';
+ data.date = new Date();
+
+ h.post.create(data, false, () => {});
+ h.post.create(data, () => {});
+
+ h.post.publish(data, false, () => {});
+ h.post.publish(data, () => {});
+
+ const renderData: Hexo.Post.RenderData = {};
+ renderData.content = 'content';
+ renderData.engine = 'ejs';
+ h.post.render(null, renderData, () => {});
+ }
+
+ {
+ h.scaffold.get('post').then(result => '');
+ h.scaffold.set('post', '').then(() => {});
+ h.scaffold.remove('post').then(() => {});
+ }
+
+ {
+ const themeConfig: Hexo['config'] = h.theme.config;
+ let v: Hexo.View | undefined;
+ h.theme.setView('path-name', {});
+ v = h.theme.getView('post');
+ if (v) {
+ console.log(v.path);
+ console.log(v.source);
+
+ v.render().then(result => {});
+ v.renderSync();
+ }
+
+ h.theme.removeView('path-name');
+ h.theme.process(() => {});
+ }
+
+ {
+ const options: Hexo.extend.Console.Options = {};
+ options.usage = '[layout] ';
+ options.arguments = [
+ {name: 'layout', desc: 'Post layout'},
+ {name: 'title', desc: 'Post title'},
+ ];
+ options.options = [
+ {name: '-r, --replace', desc: 'Replace existing files'},
+ ];
+ options.desc = 'desc';
+
+ h.extend.console.register('name', 'description', options, args => {
+ const a: ParsedArgs = args;
+ });
+ h.extend.console.register('name', options, args => {});
+ h.extend.console.register('name', 'description', args => {});
+ h.extend.console.register('name', args => {});
+ }
+
+ {
+ h.extend.deployer.register('name', args => {
+ console.log(args.type);
+ console.log(args.someExtraArg);
+ });
+ }
+
+ {
+ h.extend.filter.register('before_post_render', data => data);
+ h.extend.filter.register('before_post_render', data => undefined);
+ h.extend.filter.register('before_post_render', data => undefined, 1);
+
+ h.extend.filter.register('after_post_render', data => data);
+ h.extend.filter.register('after_post_render', data => undefined);
+ h.extend.filter.register('after_post_render', data => undefined, 1);
+
+ h.extend.filter.register('before_exit', () => {});
+ h.extend.filter.register('before_exit', () => {}, 1);
+
+ h.extend.filter.register('before_generate', data => data);
+ h.extend.filter.register('before_generate', data => undefined);
+ h.extend.filter.register('before_generate', data => undefined, 1);
+
+ h.extend.filter.register('after_generate', () => {});
+ h.extend.filter.register('after_generate', () => {}, 1);
+
+ h.extend.filter.register('template_locals', locals => locals);
+ h.extend.filter.register('template_locals', locals => undefined);
+ h.extend.filter.register('template_locals', locals => undefined, 1);
+
+ h.extend.filter.register('after_init', () => {});
+ h.extend.filter.register('after_init', () => {}, 1);
+
+ h.extend.filter.register('new_post_path', (data, replace) => undefined);
+ h.extend.filter.register('new_post_path', (data, replace) => undefined, 1);
+
+ h.extend.filter.register('post_permalink', permalink => permalink);
+ h.extend.filter.register('post_permalink', permalink => permalink, 1);
+
+ h.extend.filter.register('after_render:html', (result, data) => result);
+ h.extend.filter.register('after_render:html', (result, data) => result, 1);
+
+ h.extend.filter.register('after_clean', () => {});
+ h.extend.filter.register('after_clean', () => {}, 1);
+
+ h.extend.filter.register('server_middleware', app => {
+ app.use((req: http.IncomingMessage, res: http.ServerResponse) => {
+ res.setHeader('X-Powered-By', 'Hexo');
+ });
+ });
+
+ const filter = (data: any) => data;
+ h.extend.filter.register('custom_filter', filter);
+ h.extend.filter.unregister('custom_filter', filter);
+
+ const options: Hexo.extend.Filter.Options = {};
+ options.args = ['foo', 'bar'];
+ options.context = h;
+ h.extend.filter.exec('custom_filter', options);
+ h.extend.filter.exec('custom_filter');
+ h.extend.filter.execSync('custom_filter', options);
+ h.extend.filter.execSync('custom_filter');
+ }
+
+ {
+ const ret: Hexo.extend.Generator.Return = {
+ data: {},
+ layout: 'layout-name',
+ path: '/',
+ };
+ h.extend.generator.register('name', local => ret);
+ h.extend.generator.register('name', local => [ret]);
+ h.extend.generator.register('name', local => {
+ console.log(local.data);
+ const categories: Hexo.Locals.Category[] = local.categories.toArray();
+ const pages: Hexo.Locals.Page[] = local.pages.toArray();
+ const posts: Hexo.Locals.Post[] = local.posts.toArray();
+ const tags: Hexo.Locals.Tag[] = local.tags.toArray();
+
+ return ret;
+ });
+ }
+
+ {
+ h.extend.helper.register('name', (...args) => {
+ return 'ret';
+ });
+ }
+
+ {
+ h.extend.migrator.register('name', args => {
+ const a: ParsedArgs = args;
+ });
+ }
+
+ {
+ let f: Hexo.Box.File;
+ h.extend.processor.register('pattern', file => f = file);
+ h.extend.processor.register(/pattern/, file => f = file);
+ h.extend.processor.register((str) => true , file => f = file);
+ h.extend.processor.register(file => f = file);
+ }
+
+ {
+ h.extend.renderer.register('ts', 'js', (data, options) => {
+ console.log(data.path);
+ console.log(data.text);
+ return 'result';
+ }, true);
+
+ h.extend.renderer.register('ts', 'js', (data, options) => Promise.resolve('result'), false);
+ h.extend.renderer.register('ts', 'js', (data, options) => Promise.resolve('result'));
+ }
+
+ {
+ const option: Hexo.extend.Tag.Options = {};
+ option.async = true;
+ option.ends = true;
+
+ h.extend.tag.register('name', (args, content) => {
+ if (content) {
+ const c: string = content;
+ }
+ const a: string[] = args;
+ return 'content';
+ });
+ }
+});
diff --git a/types/hexo/index.d.ts b/types/hexo/index.d.ts
new file mode 100644
index 0000000000..0f3a9dcc78
--- /dev/null
+++ b/types/hexo/index.d.ts
@@ -0,0 +1,976 @@
+// Type definitions for hexo 3.8
+// Project: https://hexo.io/
+// Definitions by: KentarouTakeda
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// TypeScript Version: 2.8
+
+import EventEmitter = require('events');
+import moment = require('moment');
+import { ParsedArgs } from 'minimist';
+import Logger = require('bunyan');
+import underscore = require('underscore');
+import connect = require('connect');
+import Stream = require('stream');
+import util = require('hexo-util');
+import fs = require('fs');
+
+declare global {
+ const hexo: Hexo;
+}
+
+interface HexoConfig {
+ [key: string]: any;
+ /**
+ * The title of your website
+ */
+ readonly title: string;
+
+ /**
+ * The subtitle of your website
+ */
+ readonly subtitle: string;
+
+ /**
+ * The description of your website
+ */
+ readonly description: string;
+
+ /*
+ * Your name
+ */
+ readonly author: string;
+
+ /**
+ * The language of your website. Use a 2-lettter ISO-639-1 code. Default is en.
+ */
+ readonly language: string;
+
+ /**
+ * The timezone of your website. Hexo uses the setting on your computer by default.
+ * You can find the list of available timezones [here]{@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones} .
+ * Some examples are `America/New_York` , `Japan` , and `UTC` .
+ */
+ readonly timezone: string;
+
+ /*
+ * The URL of your website
+ */
+ readonly url: string;
+
+ /**
+ * The root directory of your website
+ */
+ readonly root: string;
+
+ /**
+ * The permalink format of articles
+ */
+ readonly permalink: string;
+
+ /**
+ * Default values of each segment in permalink
+ */
+ readonly permalink_defaults: string|null;
+
+ /**
+ * Source folder. Where your content is stored
+ */
+ readonly source_dir: string;
+
+ /**
+ * Public folder. Where the static site will be generated
+ */
+ readonly public_dir: string;
+
+ /**
+ * Tag directory
+ */
+ readonly tag_dir: string;
+
+ /**
+ * Archive directory
+ */
+ readonly archive_dir: string;
+
+ /**
+ * Category directory
+ */
+ readonly category_dir: string;
+
+ /**
+ * Include code directory (subdirectory of source_dir)
+ */
+ readonly code_dir: string;
+
+ /**
+ * i18n directory
+ */
+ readonly i18n_dir: string;
+
+ /**
+ * Paths that will be copied to public raw, without being rendered. You can use glob expressions for path matching.
+ */
+ readonly skip_render: string|string[]|null;
+
+ /**
+ * The filename format for new posts
+ */
+ readonly new_post_name: string;
+
+ /**
+ * Default layout
+ */
+ readonly default_layout: string;
+
+ /**
+ * Transform titles into title case?
+ */
+ readonly titlecase: boolean;
+
+ /**
+ * Open external links in a new tab?
+ */
+ readonly external_link: boolean;
+
+ /**
+ * Transform filenames to 1 lower case; 2 upper case
+ */
+ readonly filename_case: number;
+
+ /**
+ * Display drafts?
+ */
+ readonly render_drafts: boolean;
+
+ /**
+ * Enable the Asset Folder?
+ */
+ readonly post_asset_folder: boolean;
+
+ /**
+ * Make links relative to the root folder?
+ */
+ readonly relative_link: boolean;
+
+ /**
+ * Display future posts?
+ */
+ readonly future: boolean;
+
+ /**
+ * Code block settings
+ */
+ readonly highlight: {
+ readonly enable: boolean;
+ readonly line_number: boolean;
+ readonly auto_detect: boolean;
+ readonly tab_replace: string|null;
+ };
+
+ /**
+ * Default category
+ */
+ readonly default_category: string;
+
+ /**
+ * Category slugs
+ */
+ readonly category_map: {[key: string]: string|number};
+
+ /**
+ * Tag slugs
+ */
+ readonly tag_map: {[key: string]: string|number};
+
+ /**
+ * Date format
+ * https://momentjs.com/
+ */
+ readonly date_format: string;
+
+ /**
+ * Time format
+ * https://momentjs.com/
+ */
+ readonly time_format: string;
+
+ /**
+ * The amount of posts displayed on a single page. 0 disables pagination
+ */
+ readonly per_page: number;
+
+ /**
+ * Pagination directory
+ */
+ readonly pagination_dir: string;
+
+ /**
+ * Theme name. false disables theming
+ */
+ readonly theme: string|false;
+
+ /**
+ * Theme configuration. Include any custom theme settings under this key to override theme defaults.
+ */
+ readonly theme_config: {[key: string]: string|number};
+
+ /**
+ * Deployment settings
+ */
+ readonly deploy: Hexo.extend.Deployer.Config | Hexo.extend.Deployer.Config | null;
+
+ /**
+ * Hexo by default ignores hidden files and folders, but setting this field will make Hexo process them
+ */
+ readonly include ?: string[];
+
+ /**
+ * Hexo process will ignore files list under this field
+ */
+ readonly exclude ?: string[];
+ readonly ignore: string[];
+}
+
+interface Model {
+ /**
+ * Warehouse method
+ * https://hexojs.github.io/warehouse/
+ */
+ toArray(): T[];
+ /**
+ * Warehouse method
+ * https://hexojs.github.io/warehouse/
+ */
+ count(): number;
+ /**
+ * Warehouse method
+ * https://hexojs.github.io/warehouse/
+ */
+ forEach(fn: (v: T, i: number) => void): void;
+ /**
+ * Warehouse method
+ * https://hexojs.github.io/warehouse/
+ */
+ filter(fn: (v: T, i: number) => boolean): Model;
+ /**
+ * Warehouse method
+ * https://hexojs.github.io/warehouse/
+ */
+ map(fn: (v: T, i: number) => U): U[];
+}
+
+interface Site {
+ posts: Model;
+ pages: Model;
+ categories: Model;
+ tags: Model;
+ data: {[key: string]: any};
+}
+
+declare class Hexo extends EventEmitter {
+ /**
+ * Create a Hexo instance.
+ * @param base the root directory of the website, `base_dir` .
+ * @param args an object containing the initialization options.
+ */
+ constructor(base?: string, args?: Hexo.InstanceOptions);
+
+ /**
+ * Load configuration and plugins.
+ */
+ init(): Promise;
+
+ /**
+ * Loading all files in the `source` folder as well as the theme data.
+ */
+ load(fn?: (err: any, value: any) => void): Promise;
+
+ /**
+ * The same things `load` does, but will also start watching for file changes continuously.
+ */
+ watch(fn?: (err: any, value: any) => void): Promise;
+
+ unwatch(): void;
+
+ /**
+ * Any console command can be called explicitly using the call method on the Hexo instance.
+ */
+ call(name: string, args?: any, fn?: (err: any, value: any) => void): Promise;
+ call(name: string, fn?: (err: any, value: any) => void): Promise;
+
+ /**
+ * You should call the `exit` method upon successful or unsuccessful completion of a console command.
+ * This allows Hexo to exit gracefully and finish up important things such as saving the database.
+ */
+ exit(err?: any): Promise;
+
+ /**
+ * Site settings in `_config.yml`
+ */
+ readonly config: HexoConfig;
+
+ readonly theme: Hexo.Theme;
+ readonly source: Hexo.Box;
+ readonly post: Hexo.Post;
+ readonly render: Hexo.Render;
+
+ /**
+ * Local variables are used for template rendering, which is the `site` variable in templates.
+ * https://hexo.io/api/locals
+ */
+ readonly locals: Hexo.Locals;
+
+ readonly base_dir: string;
+
+ /**
+ * Public folder. Where the static site will be generated
+ */
+ readonly public_dir: string;
+
+ /**
+ * Source folder. Where your content is stored
+ */
+ readonly source_dir: string;
+
+ readonly plugin_dir: string;
+ readonly script_dir: string;
+ readonly scaffold_dir: string;
+ readonly theme_dir: string;
+ readonly theme_script_dir: string;
+ readonly config_path: string;
+ readonly env: {
+ readonly args: ParsedArgs;
+ readonly debug: boolean;
+ readonly safe: boolean;
+ readonly silent: boolean;
+ readonly env: string;
+ readonly version: string;
+ readonly init: boolean;
+ };
+
+ /**
+ * Logger object
+ * https://www.npmjs.com/package/bunyan
+ */
+ readonly log: Logger;
+
+ readonly extend: {
+ /**
+ * The console forms the bridge between Hexo and its users. It registers and describes the available console commands.
+ */
+ readonly console: Hexo.extend.Console;
+ /**
+ * A deployer helps users quickly deploy their site to a remote server without complicated commands.
+ */
+ readonly deployer: Hexo.extend.Deployer;
+ /**
+ * A filter is used to modify some specified data. Hexo passes data to filters in sequence and the filters then modify the data one after the other.
+ */
+ readonly filter: Hexo.extend.Filter;
+ /**
+ * A generator builds routes based on processed files.
+ */
+ readonly generator: Hexo.extend.Generator;
+ /**
+ * A helper makes it easy to quickly add snippets to your templates. We recommend using helpers instead of templates when you’re dealing with more complicated code.
+ */
+ readonly helper: Hexo.extend.Helper;
+ /**
+ * A migrator helps users migrate from other systems to Hexo.
+ */
+ readonly migrator: Hexo.extend.Migrator;
+ /**
+ * A processor is used to process source files in the source folder.
+ */
+ readonly processor: Hexo.extend.Processor;
+ /**
+ * A renderer is used to render content.
+ */
+ readonly renderer: Hexo.extend.Renderer;
+ /**
+ * A tag allows users to quickly and easily insert snippets into their posts.
+ */
+ readonly tag: Hexo.extend.Tag;
+ };
+
+ readonly route: Hexo.Router;
+ readonly scaffold: Hexo.Scaffold;
+
+ /**
+ * Emitted before deployment begins.
+ */
+ on(ev: 'deployBefore', fn: () => void): this;
+
+ /**
+ * Emitted after deployment finishes.
+ */
+ on(ev: 'deployAfter', fn: () => void): this;
+
+ /**
+ * Emitted before Hexo exits.
+ */
+ on(ev: 'exit', fn: (err: any) => void): this;
+
+ /**
+ * Emitted before generation begins.
+ */
+ on(ev: 'generateBefore', fn: () => void): this;
+
+ /**
+ * Emitted after generation finishes.
+ */
+ on(ev: 'generateAfter', fn: () => void): this;
+
+ /**
+ * Emitted after a new post has been created. This event returns the post data:
+ */
+ on(ev: 'new', fn: (post: {path: string, content: string}) => void): this;
+
+ /**
+ * Emitted before processing begins. This event returns a path representing the root directory of the box.
+ */
+ on(ev: 'processBefore', fn: (type: Hexo.Box.File['type'], path: string) => void): this;
+
+ /**
+ * Emitted after processing finishes. This event returns a path representing the root directory of the box.
+ */
+ on(ev: 'processAfter', fn: (type: Hexo.Box.File['type'], path: string) => void): this;
+
+ /**
+ * Emitted after initialization finishes.
+ */
+ on(ev: 'ready', fn: () => void): this;
+}
+
+declare namespace Hexo {
+ interface InstanceOptions {
+ debug?: boolean;
+ safe?: boolean;
+ silent?: boolean;
+ config?: string;
+ }
+
+ interface Locals {
+ get(type: 'posts'): Model;
+ get(type: 'pages'): Model;
+ get(type: 'categories'): Model;
+ get(type: 'tags'): Model;
+ /**
+ * Get a Variable
+ */
+ get(type: string): any;
+
+ /**
+ * Set a Variable
+ */
+ set(type: string, fn: () => any): this;
+
+ /**
+ * Remove a Variable
+ */
+ remove(type: string): this;
+
+ /**
+ * Get All Variable
+ */
+ toObject(): any;
+
+ /**
+ * Invalidate the cache
+ */
+ invalidate(): this;
+ }
+ namespace Locals {
+ interface Page {
+ title: string;
+ date: moment.Moment;
+ updated?: moment.Moment;
+ comments: boolean;
+ layout: string;
+ content: string;
+ excerpt?: string;
+ more?: string;
+ source: string;
+ full_source: string;
+ path: string;
+ permalink: string;
+ prev?: null|Page;
+ next?: null|Page;
+ raw?: string;
+ photos?: string[];
+ link?: string;
+ [key: string]: any;
+ }
+
+ interface Post extends Page {
+ published?: boolean;
+ categories?: string[];
+ tags: string[];
+ }
+
+ interface Tag {
+ name: string;
+ slug: string;
+ path: string;
+ permalink: string;
+ posts: Model;
+ length: number;
+ }
+ interface Category extends Tag {
+ parent: string;
+ }
+ }
+
+ namespace extend {
+ interface Console {
+ register(name: string, desc: string, options: Console.Options, fn: (args: ParsedArgs) => void): void;
+ register(name: string, options: Console.Options, fn: (args: ParsedArgs) => void): void;
+ register(name: string, desc: string, fn: (args: ParsedArgs) => void): void;
+ register(name: string, fn: (args: ParsedArgs) => void): void;
+ }
+ namespace Console {
+ interface Options {
+ /**
+ * The usage of a console command.
+ */
+ usage?: string;
+
+ /**
+ * The description of each argument of a console command.
+ */
+ arguments?: Array<{name: string, desc: string}>;
+
+ /**
+ * The description of each option of a console command.
+ */
+ options?: Array<{name: string, desc: string}>;
+
+ /**
+ * More detailed information about a console command.
+ */
+ desc?: string;
+ }
+ }
+
+ interface Deployer {
+ register(name: string, fn: (args: Deployer.Config) => void): void;
+ }
+ namespace Deployer {
+ interface Config {
+ readonly type: string|undefined;
+ readonly [key: string]: any;
+ }
+ }
+
+ interface Filter {
+ register(type: string, fn: (data: any, ...args: any[]) => any, priority?: number): void;
+
+ /**
+ * Executed before a post is rendered. Refer to post rendering to learn the execution steps.
+ */
+ register(type: 'before_post_render', fn: (data: { content: string, [key: string]: any }) => { content: string, [key: string]: any }|void, priority?: number): void;
+
+ /**
+ * Executed after a post is rendered. Refer to post rendering to learn the execution steps.
+ */
+ register(type: 'after_post_render', fn: (data: { content: string, [key: string]: any }) => { content: string, [key: string]: any }|void, priority?: number): void;
+
+ /**
+ * Executed before Hexo is about to exit – this will run right after `hexo.exit` is called.
+ */
+ register(type: 'before_exit', fn: () => void, priority?: number): void;
+
+ /**
+ * Executed before generation begins.
+ */
+ register(type: 'before_generate', fn: (data: any) => any, priority?: number): void;
+
+ /**
+ * Executed after generation finishes.
+ */
+ register(type: 'after_generate', fn: () => void, priority?: number): void;
+
+ /**
+ * Modify [local variables](https://hexo.io/docs/variables) in templates.
+ */
+ register(type: 'template_locals', fn: (locals: TemplateLocals) => TemplateLocals|void, priority?: number): void;
+
+ /**
+ * Executed after Hexo is initialized – this will run right after `hexo.init` completes.
+ */
+ register(type: 'after_init', fn: () => void, priority?: number): void;
+
+ /**
+ * Executed when creating a post to determine the path of new posts.
+ */
+ register(type: 'new_post_path', fn: (data: Post.Data, replace: boolean|undefined) => void, priority?: number): void;
+
+ /**
+ * Used to determine the permalink of posts.
+ */
+ register(type: 'post_permalink', fn: (permalink: string) => string, priority?: number): void;
+
+ /**
+ * Executed after rendering finishes. You can see rendering for more info.
+ */
+ register(type: 'after_render:html', fn: (result: string, data: {path: string, text: string, [key: string]: any}) => string|void, priority?: number): void;
+
+ /**
+ * Executed after generated files and cache are removed with hexo clean command.
+ */
+ register(type: 'after_clean', fn: () => void, priority?: number): void;
+
+ /**
+ * Add middleware to the server. app is a Connect instance.
+ */
+ register(type: 'server_middleware', fn: (app: connect.Server) => connect.Server|void, priority?: number): void;
+
+ unregister(type: string, fn: (...args: any[]) => any): void;
+ exec(type: string, data?: any, options?: Filter.Options): any;
+ execSync(type: string, data?: any, options?: Filter.Options): any;
+ }
+ namespace Filter {
+ interface Options {
+ /**
+ * `hexo` object.
+ */
+ context?: Hexo;
+ /**
+ * Arguments. This must be an array.
+ */
+ args?: any[];
+ }
+ }
+
+ interface Generator {
+ register(name: string, fn: (locals: Site) => Generator.Return| Generator.Return[]): void;
+ }
+ namespace Generator {
+ interface Return {
+ /**
+ * Path not including the prefixing `/` .
+ */
+ path: string;
+
+ /**
+ * Layout. Specify the layouts for rendering. The value can be a string or an array. If it’s ignored then the route will return data directly.
+ */
+ layout: string|string[];
+
+ data: any;
+ }
+ }
+
+ interface Helper {
+ register(name: string, fn: (...args: any[]) => any): void;
+ }
+
+ interface Migrator {
+ register(name: string, fn: (args: ParsedArgs, fn: (err: any) => void) => void): void;
+ }
+
+ interface Processor {
+ register(pattern: RegExp | string | ((str: string) => any), fn: (file: Box.File) => void): void;
+ register(fn: (file: Box.File) => void): void;
+ }
+
+ interface Renderer {
+ register(srcExt: string, outExt: string, fn: (data: HexoRendererData, options: any) => string, sync: true): void;
+ register(srcExt: string, outExt: string, fn: (data: HexoRendererData, options: any) => Promise, sync: false): void;
+ register(srcExt: string, outExt: string, fn: (data: HexoRendererData, options: any) => Promise): void;
+ }
+
+ interface Tag {
+ register(name: string, fn: (args: string[], content: string|undefined) => string, options?: Tag.Options): void;
+ }
+ namespace Tag {
+ interface Options {
+ ends?: boolean;
+ async?: boolean;
+ }
+ }
+ }
+
+ interface Router {
+ /**
+ * The `get` method returns a `Stream`.
+ */
+ get(path: string): Router.RouteStream|undefined;
+
+ /**
+ * The `set` method takes a string, a `Buffer` or a function.
+ */
+ set(path: string, data: string|Buffer|util.Pattern|Router.Data): this;
+
+ /**
+ * Remove a Path
+ */
+ remove(path: string): this;
+
+ /**
+ * Get the List of Routes
+ */
+ list(): string[];
+
+ /**
+ * The `format` method transforms a string to a valid path.
+ */
+ format(path: string): string;
+ }
+ namespace Router {
+ interface Data {
+ data: string | Buffer | Callback;
+ modified: boolean;
+ }
+
+ interface RouteStream extends Stream.Readable {
+ readonly modified: boolean;
+ }
+
+ type Callback = ((err: any, result: string) => void) | (() => Promise);
+ }
+
+ interface Scaffold {
+ /**
+ * Get a Scaffold
+ */
+ get(name: string, fn?: (err: any, result: string) => void): Promise;
+ /**
+ * Set a Scaffold
+ */
+ set(name: string, content: string, fn?: (err: any) => void): Promise;
+ /**
+ * Remove a Scaffold
+ */
+ remove(name: string, fn?: (err: any) => void): Promise;
+ }
+
+ interface Box extends EventEmitter {
+ /**
+ * Loads all files in the folder.
+ */
+ process(fn: (err: any) => void): Promise;
+ /**
+ * Loads all files in the folder and start watching for file changes.
+ */
+ watch(fn?: (err: any) => void): Promise;
+ /**
+ * Stop watching.
+ */
+ unwatch(): void;
+
+ /**
+ * A processor is an essential element of `Box` and is used to process files.
+ * You can use path matching as described above to restrict what exactly the processor should process.
+ * Register a new processor with the `addProcessor` method.
+ */
+ addProcessor(pattern: string|RegExp|util.Pattern, fn: (file: Box.File) => void): void;
+ }
+ namespace Box {
+ interface File {
+ /**
+ * Full path of the file
+ */
+ readonly source: string;
+
+ /**
+ * Relative path to the box of the file
+ */
+ readonly path: string;
+
+ /**
+ * File type. The value can be `create` , `update` , `skip`, `delete` .
+ */
+ readonly type: 'create' | 'update' | 'skip' | 'delete';
+
+ /**
+ * The information from path matching.
+ */
+ readonly params: any;
+
+ /**
+ * Read a file
+ */
+ read(option?: {encoding?: string|null, flag?: string}, fn?: (err: any, result: string|Buffer) => void): Promise;
+ read(fn?: (err: any, result: string|Buffer) => void): Promise;
+
+ /**
+ * Read a file synchronously
+ */
+ readSync(option?: {encoding?: string|null, flag?: string}): string|Buffer;
+
+ /**
+ * Read the status of a file
+ */
+ stat(fn?: (err: any, result: fs.Stats) => void): Promise;
+
+ /**
+ * Read the status of a file synchronously
+ */
+ statSync(): fs.Stats;
+
+ /**
+ * Render a file
+ */
+ render(fn?: (err: any, result: string) => void): Promise;
+ render(option?: any, fn?: (err: any, result: string) => void): Promise;
+
+ /**
+ * Render a file synchronously
+ */
+ renderSync(option?: any): string;
+ }
+ }
+
+ interface Render {
+ render(data: Render.Data, option?: any, fn?: (err: any, result: string) => void): Promise;
+ render(data: Render.Data, fn?: (err: any, result: string) => void): Promise;
+ renderSync(data: Render.Data, option?: any): string;
+
+ /**
+ * Check whether a file is renderable synchronously.
+ */
+ isRenderable(path: string): boolean;
+
+ /**
+ * Check whether a file is renderable.
+ */
+ isRenderableSync(path: string): boolean;
+
+ /**
+ * Get the Output Extension
+ */
+ getOutput(path: string): string;
+ }
+ namespace Render {
+ interface Data {
+ text?: string;
+ engine?: string;
+ path?: string;
+ }
+ }
+
+ interface Post {
+ /**
+ * Create a Post
+ */
+ create(data: Post.Data, replace?: boolean, fn?: (err: any) => void): Promise;
+ create(data: Post.Data, fn?: (err: any) => void): Promise;
+
+ /**
+ * Publish a Draft
+ */
+ publish(data: Post.Data, replace?: boolean, fn?: (err: any) => void): Promise;
+ publish(data: Post.Data, fn?: (err: any) => void): Promise;
+
+ render(source: string|null|undefined, data: Post.RenderData, fn: (err: any) => void): Promise;
+ }
+ namespace Post {
+ interface Data {
+ title?: string;
+ slug?: string;
+ layout?: string;
+ path?: string;
+ date?: moment.MomentInput;
+ }
+ interface RenderData {
+ engine?: string;
+ content?: string;
+ }
+ }
+
+ interface Theme extends Box {
+ config: HexoConfig;
+
+ /**
+ * Get a View
+ */
+ getView(path: string): View|undefined;
+
+ /**
+ * Set a View
+ */
+ setView(path: string, data: any): void;
+
+ /**
+ * Remove a View
+ */
+ removeView(path: string): void;
+ }
+
+ interface View {
+ readonly path: string;
+ readonly source: string;
+
+ /**
+ * Remove a View
+ */
+ render(options?: any, fn?: (err: any, result: string) => void): Promise;
+ render(fn: (err: any, result: string) => void): Promise;
+
+ /**
+ * Remove a View synchronously.
+ */
+ renderSync(options?: any): string;
+ }
+}
+
+interface TemplateLocals {
+ /**
+ * Underscore object
+ */
+ _: underscore.UnderscoreStatic;
+ page: Hexo.Locals.Post | Hexo.Locals.Page | Hexo.Locals.Category | Hexo.Locals.Tag | IndexPage | ArchivePage | CategoryPage | TagPage;
+ path: string;
+ url: string;
+
+ /**
+ * Site settings in `_config.yml`
+ */
+ config: HexoConfig;
+ theme: HexoConfig;
+ env: Hexo['env'];
+ layout: string;
+ view_dir: string;
+ site: any;
+}
+
+interface IndexPage {
+ per_page?: number;
+ total?: number;
+ current?: number;
+ current_url?: string;
+ posts?: object;
+ prev?: number;
+ prev_link?: string;
+ next?: number;
+ next_link?: string;
+ path?: string;
+}
+
+interface ArchivePage extends IndexPage {
+ archive?: boolean;
+ year?: number;
+ month?: number;
+}
+
+interface CategoryPage extends IndexPage {
+ category: string;
+}
+
+interface TagPage extends IndexPage {
+ tag: string;
+}
+
+interface HexoRendererData {
+ /**
+ * File content.
+ */
+ readonly text: string;
+ /**
+ * File path.
+ */
+ readonly path?: string;
+}
+
+export = Hexo;
diff --git a/types/fastify-static/tsconfig.json b/types/hexo/tsconfig.json
similarity index 65%
rename from types/fastify-static/tsconfig.json
rename to types/hexo/tsconfig.json
index bdfa7d40c6..6e37a832a0 100644
--- a/types/fastify-static/tsconfig.json
+++ b/types/hexo/tsconfig.json
@@ -1,16 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
- "lib": ["es6"],
+ "lib": [
+ "es6"
+ ],
"noImplicitAny": true,
"noImplicitThis": true,
- "strictFunctionTypes": true,
"strictNullChecks": true,
+ "strictFunctionTypes": true,
"baseUrl": "../",
- "typeRoots": ["../"],
+ "typeRoots": [
+ "../"
+ ],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
- "files": ["index.d.ts", "fastify-static-tests.ts"]
+ "files": [
+ "index.d.ts",
+ "hexo-tests.ts"
+ ]
}
diff --git a/types/hexo/tslint.json b/types/hexo/tslint.json
new file mode 100644
index 0000000000..d2e0e4cec1
--- /dev/null
+++ b/types/hexo/tslint.json
@@ -0,0 +1,7 @@
+{
+ "extends": "dtslint/dt.json",
+ "rules": {
+ "unified-signatures": false
+ }
+
+}
diff --git a/types/iobroker/index.d.ts b/types/iobroker/index.d.ts
index 6beeccb08f..0075f8a273 100644
--- a/types/iobroker/index.d.ts
+++ b/types/iobroker/index.d.ts
@@ -2,7 +2,7 @@
// Project: https://github.com/ioBroker/ioBroker
// Definitions by: AlCalzone
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-// TypeScript Version: 3.0
+// TypeScript Version: 3.2
// Note: This is not the definition for the package `iobroker`,
// which is just an installer, not a library.
@@ -296,14 +296,28 @@ declare global {
/** attached history information */
history?: any;
+
+ /** Custom settings for this state */
+ custom?: Record;
}
interface ChannelCommon extends ObjectCommon {
/** description of this channel */
desc?: string;
+
+ // Only states can have common.custom
+ custom?: undefined;
}
- type OtherCommon = ObjectCommon & {
+ interface DeviceCommon extends ObjectCommon {
+ // Only states can have common.custom
+ custom?: undefined;
+ // TODO: any other definition for device?
+ }
+ interface OtherCommon extends ObjectCommon {
[propName: string]: any;
- };
+
+ // Only states can have common.custom
+ custom?: undefined;
+ }
interface BaseObject {
/** The ID of this object */
@@ -311,7 +325,7 @@ declare global {
native: Record;
enums?: Record;
type: string; // specified in the derived interfaces
- common: ObjectCommon;
+ common: StateCommon | ChannelCommon | DeviceCommon | OtherCommon;
acl?: ObjectACL;
}
@@ -335,10 +349,10 @@ declare global {
interface DeviceObject extends BaseObject {
type: "device";
- common: ObjectCommon; // TODO: any definition for device?
+ common: DeviceCommon;
}
interface PartialDeviceObject extends Partial> {
- common?: Partial;
+ common?: Partial;
}
interface OtherObject extends BaseObject {
@@ -350,11 +364,15 @@ declare global {
}
type Object = StateObject | ChannelObject | DeviceObject | OtherObject;
+
+ type SettableObjectWorker =
+ Pick> & {
+ _id?: T["_id"];
+ acl?: T["acl"];
+ };
+
// In set[Foreign]Object[NotExists] methods, the ID and acl of the object is optional
- interface SettableObject extends Pick> {
- _id?: ioBroker.Object["_id"];
- acl?: ioBroker.Object["acl"];
- }
+ type SettableObject = SettableObjectWorker;
type PartialObject = PartialStateObject | PartialChannelObject | PartialDeviceObject | PartialOtherObject;
/** Defines access rights for a single file */
diff --git a/types/iobroker/iobroker-tests.ts b/types/iobroker/iobroker-tests.ts
index 01ab0c6fc4..a2c89cb893 100644
--- a/types/iobroker/iobroker-tests.ts
+++ b/types/iobroker/iobroker-tests.ts
@@ -209,8 +209,8 @@ switch (adapter.log.level) {
adapter.sendTo("foo.0", "command", "message");
adapter.sendTo("foo.0", "message");
-adapter.sendTo("foo.0", "command", {msg: "message"});
-adapter.sendTo("foo.0", {msg: "message"});
+adapter.sendTo("foo.0", "command", { msg: "message" });
+adapter.sendTo("foo.0", { msg: "message" });
function handleMessageResponse(response?: ioBroker.Message) {
if (!response) return;
@@ -226,28 +226,28 @@ function handleMessageResponse(response?: ioBroker.Message) {
}
adapter.sendTo("foo.0", "command", "message", handleMessageResponse);
adapter.sendTo("foo.0", "message", handleMessageResponse);
-adapter.sendTo("foo.0", "command", {msg: "message"}, handleMessageResponse);
-adapter.sendTo("foo.0", {msg: "message"}, handleMessageResponse);
+adapter.sendTo("foo.0", "command", { msg: "message" }, handleMessageResponse);
+adapter.sendTo("foo.0", { msg: "message" }, handleMessageResponse);
adapter.sendToAsync("foo.0", "command", "message").then(handleMessageResponse);
adapter.sendToAsync("foo.0", "message").then(handleMessageResponse);
-adapter.sendToAsync("foo.0", "command", {msg: "message"}).then(handleMessageResponse);
-adapter.sendToAsync("foo.0", {msg: "message"}).then(handleMessageResponse);
+adapter.sendToAsync("foo.0", "command", { msg: "message" }).then(handleMessageResponse);
+adapter.sendToAsync("foo.0", { msg: "message" }).then(handleMessageResponse);
adapter.sendToHost("host-foo", "command", "message");
adapter.sendToHost("host-foo", "message");
-adapter.sendToHost("host-foo", "command", {msg: "message"});
-adapter.sendToHost("host-foo", {msg: "message"});
+adapter.sendToHost("host-foo", "command", { msg: "message" });
+adapter.sendToHost("host-foo", { msg: "message" });
adapter.sendToHost("host-foo", "command", "message", handleMessageResponse);
adapter.sendToHost("host-foo", "message", handleMessageResponse);
-adapter.sendToHost("host-foo", "command", {msg: "message"}, handleMessageResponse);
-adapter.sendToHost("host-foo", {msg: "message"}, handleMessageResponse);
+adapter.sendToHost("host-foo", "command", { msg: "message" }, handleMessageResponse);
+adapter.sendToHost("host-foo", { msg: "message" }, handleMessageResponse);
adapter.sendToHostAsync("host-foo", "command", "message").then(handleMessageResponse);
adapter.sendToHostAsync("host-foo", "message").then(handleMessageResponse);
-adapter.sendToHostAsync("host-foo", "command", {msg: "message"}).then(handleMessageResponse);
-adapter.sendToHostAsync("host-foo", {msg: "message"}).then(handleMessageResponse);
+adapter.sendToHostAsync("host-foo", "command", { msg: "message" }).then(handleMessageResponse);
+adapter.sendToHostAsync("host-foo", { msg: "message" }).then(handleMessageResponse);
function handleError(err?: string) { }
adapter.subscribeStates("*", handleError);
@@ -259,3 +259,30 @@ adapter.subscribeStatesAsync("*").catch(handleError);
adapter.subscribeForeignStatesAsync("*").catch(handleError);
adapter.unsubscribeStatesAsync("*").catch(handleError);
adapter.unsubscribeForeignStatesAsync("*").catch(handleError);
+
+// Repro from https://github.com/ioBroker/adapter-core/issues/3
+const repro1: ioBroker.ObjectChangeHandler = (id, obj) => {
+ if (!obj || !obj.common) return;
+ if (obj.common.custom) {
+ const test1: ioBroker.StateCommon = obj.common;
+ }
+ obj
+ && obj.common
+ && obj.common.custom
+ && obj.common.custom["adapter.0"]
+ && obj.common.custom["adapter.0"].enabled
+ ;
+};
+
+// Repro from https://github.com/ioBroker/adapter-core/issues/4
+function repro2() {
+ // Prepare custom object
+ const obj = {
+ common: {
+ custom: {
+ "adapter.namespace": { start_day: null as any }
+ }
+ }
+ };
+ adapter.extendForeignObject("obj.id", obj, (err) => { });
+}
diff --git a/types/irc/index.d.ts b/types/irc/index.d.ts
index a7b163ca6e..6c222c428d 100644
--- a/types/irc/index.d.ts
+++ b/types/irc/index.d.ts
@@ -8,8 +8,8 @@
/** This library provides IRC client functionality. */
import events = require('events');
-import crypto = require('crypto');
import net = require('net');
+import tls = require('tls');
/** This library provides IRC client functionality. */
declare namespace NodeIRC {
@@ -287,7 +287,7 @@ declare namespace NodeIRC {
* Should SSL be used? Can either be true or crypto credentials.
* @default false
*/
- secure?: boolean | crypto.Credentials;
+ secure?: boolean | tls.SecureContext;
/**
* Should we accept self-signed certificates?
diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts
index 840d9b7fa0..d66e509c83 100644
--- a/types/jest/index.d.ts
+++ b/types/jest/index.d.ts
@@ -213,9 +213,9 @@ declare namespace jest {
* spy.mockRestore();
* });
*/
- function spyOn(object: T, method: M, accessType: 'get'): SpyInstance;
- function spyOn(object: T, method: M, accessType: 'set'): SpyInstance;
- function spyOn(object: T, method: M): T[M] extends (...args: any[]) => any ? SpyInstance, ArgsType> : never;
+ function spyOn>(object: T, method: M, accessType: 'get'): SpyInstance;
+ function spyOn>(object: T, method: M, accessType: 'set'): SpyInstance;
+ function spyOn>(object: T, method: M): T[M] extends (...args: any[]) => any ? SpyInstance, ArgsType> : never;
/**
* Indicates that the module system should never return a mocked version of
* the specified module from require() (e.g. that it should always return the real module).
@@ -238,6 +238,9 @@ declare namespace jest {
type ArgsType = T extends (...args: infer A) => any ? A : never;
type RejectedValue = T extends PromiseLike ? any : never;
type ResolvedValue = T extends PromiseLike ? U | T : never;
+ // see https://github.com/Microsoft/TypeScript/issues/25215
+ type NonFunctionPropertyNames = { [K in keyof T]: T[K] extends (...args: any[]) => any ? never : K }[keyof T] & string;
+ type FunctionPropertyNames = { [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never }[keyof T] & string;
interface DoneCallback {
(...args: any[]): any;
diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts
index 00ccd38106..15702d45a4 100644
--- a/types/jest/jest-tests.ts
+++ b/types/jest/jest-tests.ts
@@ -360,24 +360,35 @@ const spiedTarget = {
class SpiedTargetClass {
private _value = 3;
+ private _value2 = '';
get value() {
return this._value;
}
set value(value) {
this._value = value;
}
+ get value2() {
+ return this._value2;
+ }
+ set value2(value2) {
+ this._value2 = value2;
+ }
}
const spiedTarget2 = new SpiedTargetClass();
+// $ExpectError
+jest.spyOn(spiedTarget, "setValue", "get");
+// $ExpectError
+jest.spyOn(spiedTarget2, "value");
+
const spy1 = jest.spyOn(spiedTarget, "returnsVoid");
-const spy2 = jest.spyOn(spiedTarget, "returnsVoid", "get");
const spy3 = jest.spyOn(spiedTarget, "returnsString");
const spy1Name: string = spy1.getMockName();
-const spy2Calls: any[][] = spy2.mock.calls;
+const spy1Calls: Array<[]> = spy1.mock.calls;
-spy2.mockClear();
-spy2.mockReset();
+spy1.mockClear();
+spy1.mockReset();
const spy3Mock = spy3
.mockImplementation(() => "")
diff --git a/types/jscodeshift/index.d.ts b/types/jscodeshift/index.d.ts
new file mode 100644
index 0000000000..e19423d928
--- /dev/null
+++ b/types/jscodeshift/index.d.ts
@@ -0,0 +1,9 @@
+// Type definitions for jscodeshift 0.6
+// Project: https://github.com/facebook/jscodeshift#readme
+// Definitions by: Brie Bunge
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// TypeScript Version: 2.9
+
+import core = require("./src/core");
+
+export = core;
diff --git a/types/jscodeshift/package.json b/types/jscodeshift/package.json
new file mode 100644
index 0000000000..a501c0f28d
--- /dev/null
+++ b/types/jscodeshift/package.json
@@ -0,0 +1,7 @@
+{
+ "private": true,
+ "dependencies": {
+ "ast-types": "0.12.1",
+ "recast": "0.17.2"
+ }
+}
diff --git a/types/jscodeshift/src/Collection.d.ts b/types/jscodeshift/src/Collection.d.ts
new file mode 100644
index 0000000000..2cab87b153
--- /dev/null
+++ b/types/jscodeshift/src/Collection.d.ts
@@ -0,0 +1,131 @@
+import recast = require("recast");
+import JSXElement = require("./collections/JSXElement");
+import NodeCollection = require("./collections/Node");
+import VariableDeclarator = require("./collections/VariableDeclarator");
+
+type ASTPath = recast.NodePath;
+
+export interface Collection
+ extends NodeCollection.TraversalMethods,
+ NodeCollection.MutationMethods,
+ VariableDeclarator.GlobalMethods,
+ VariableDeclarator.TransformMethods,
+ JSXElement.GlobalMethods,
+ JSXElement.TraversalMethods {
+ /**
+ * @param paths An array of AST paths
+ * @param parent A parent collection
+ * @param types An array of types all the paths in the collection
+ * have in common. If not passed, it will be inferred from the paths.
+ */
+ new (paths: Array>, parent: Collection, types?: Array>): this;
+
+ /**
+ * Returns a new collection containing the nodes for which the callback returns true.
+ */
+ filter(
+ callback: (path: ASTPath, i: number, paths: Array>) => path is ASTPath