Skip to content

Commit 80e0c67

Browse files
Use node.d.ts from @types (#2451)
Currently we are using `node.d.ts` from version `0.11.x`. In order to get latest updates, remove our own version of node.d.ts and use the one from `@types`. Use the version for Node 6. Fix code according to new definitions. Introduce ICliGlobal interface in order to describe the global object that's used from CLI (we add some properties to the global object). Add definition file for `xmlhttprequest` module. Add definitions for Eqatec Analytics. Modify `ws.d.ts` according to latest changes.
1 parent 7d95fc5 commit 80e0c67

File tree

5 files changed

+37
-32
lines changed

5 files changed

+37
-32
lines changed

lib/definitions/ws.d.ts

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// Definitions by: Paul Loyd <https://github.com/loyd>
44
// Definitions: https://github.com/borisyankov/DefinitelyTyped
55

6-
/// <reference path="../common/definitions/node.d.ts" />
7-
86
declare module "ws" {
97
import events = require('events');
108
import http = require('http');
@@ -69,21 +67,21 @@ declare module "ws" {
6967
addEventListener(method: string, listener?: () => void): void;
7068

7169
// Events
72-
on(event: 'error', cb: (err: Error) => void): WebSocket;
73-
on(event: 'close', cb: (code: number, message: string) => void): WebSocket;
74-
on(event: 'message', cb: (data: any, flags: {binary: boolean}) => void): WebSocket;
75-
on(event: 'ping', cb: (data: any, flags: {binary: boolean}) => void): WebSocket;
76-
on(event: 'pong', cb: (data: any, flags: {binary: boolean}) => void): WebSocket;
77-
on(event: 'open', cb: () => void): WebSocket;
78-
on(event: string, listener: () => void): WebSocket;
79-
80-
addListener(event: 'error', cb: (err: Error) => void): WebSocket;
81-
addListener(event: 'close', cb: (code: number, message: string) => void): WebSocket;
82-
addListener(event: 'message', cb: (data: any, flags: {binary: boolean}) => void): WebSocket;
83-
addListener(event: 'ping', cb: (data: any, flags: {binary: boolean}) => void): WebSocket;
84-
addListener(event: 'pong', cb: (data: any, flags: {binary: boolean}) => void): WebSocket;
85-
addListener(event: 'open', cb: () => void): WebSocket;
86-
addListener(event: string, listener: () => void): WebSocket;
70+
on(event: 'error', cb: (err: Error) => void): this;
71+
on(event: 'close', cb: (code: number, message: string) => void): this;
72+
on(event: 'message', cb: (data: any, flags: {binary: boolean}) => void): this;
73+
on(event: 'ping', cb: (data: any, flags: {binary: boolean}) => void): this;
74+
on(event: 'pong', cb: (data: any, flags: {binary: boolean}) => void): this;
75+
on(event: 'open', cb: () => void): this;
76+
on(event: string, listener: () => void): this;
77+
78+
addListener(event: 'error', cb: (err: Error) => void): this;
79+
addListener(event: 'close', cb: (code: number, message: string) => void): this;
80+
addListener(event: 'message', cb: (data: any, flags: {binary: boolean}) => void): this;
81+
addListener(event: 'ping', cb: (data: any, flags: {binary: boolean}) => void): this;
82+
addListener(event: 'pong', cb: (data: any, flags: {binary: boolean}) => void): this;
83+
addListener(event: 'open', cb: () => void): this;
84+
addListener(event: string, listener: () => void): this;
8785
}
8886

8987
module WebSocket {
@@ -115,15 +113,15 @@ declare module "ws" {
115113
upgradeHead: Buffer, callback: (client: WebSocket) => void): void;
116114

117115
// Events
118-
on(event: 'error', cb: (err: Error) => void): Server;
119-
on(event: 'headers', cb: (headers: string[]) => void): Server;
120-
on(event: 'connection', cb: (client: WebSocket) => void): Server;
121-
on(event: string, listener: () => void): Server;
122-
123-
addListener(event: 'error', cb: (err: Error) => void): Server;
124-
addListener(event: 'headers', cb: (headers: string[]) => void): Server;
125-
addListener(event: 'connection', cb: (client: WebSocket) => void): Server;
126-
addListener(event: string, listener: () => void): Server;
116+
on(event: 'error', cb: (err: Error) => void): this;
117+
on(event: 'headers', cb: (headers: string[]) => void): this;
118+
on(event: 'connection', cb: (client: WebSocket) => void): this;
119+
on(event: string, listener: () => void): this;
120+
121+
addListener(event: 'error', cb: (err: Error) => void): this;
122+
addListener(event: 'headers', cb: (headers: string[]) => void): this;
123+
addListener(event: 'connection', cb: (client: WebSocket) => void): this;
124+
addListener(event: string, listener: () => void): this;
127125
}
128126

129127
export function createServer(options?: IServerOptions,

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
"devDependencies": {
8484
"@types/chai": "3.4.34",
8585
"@types/chai-as-promised": "0.0.29",
86+
"@types/lodash": "4.14.50",
87+
"@types/node": "6.0.61",
8688
"@types/source-map": "0.5.0",
8789
"chai": "3.5.0",
8890
"chai-as-promised": "6.0.0",

test/stubs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class FileSystemStub implements IFileSystem {
101101

102102
openFile(filename: string): void { }
103103

104-
createReadStream(path: string, options?: { flags?: string; encoding?: string; fd?: string; mode?: number; bufferSize?: number }): any {
104+
createReadStream(path: string, options?: { flags?: string; encoding?: string; fd?: number; mode?: number; bufferSize?: number }): any {
105105
return undefined;
106106
}
107107

test/test-bootstrap.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
import * as shelljs from "shelljs";
2+
import { use } from "chai";
3+
24
shelljs.config.silent = true;
35
shelljs.config.fatal = true;
4-
global._ = require("lodash");
5-
global.$injector = require("../lib/common/yok").injector;
6-
import { use } from "chai";
6+
7+
const cliGlobal = <ICliGlobal>global;
8+
9+
cliGlobal._ = require("lodash");
10+
cliGlobal.$injector = require("../lib/common/yok").injector;
11+
712
use(require("chai-as-promised"));
813

914
$injector.register("analyticsService", {
10-
trackException: (): {wait(): void} => {
15+
trackException: (): { wait(): void } => {
1116
return {
1217
wait: () => undefined
1318
};

0 commit comments

Comments
 (0)