soywiz-archive / typescript-node-definitions Goto Github PK
View Code? Open in Web Editor NEWTypeScript's typings for some popular node.js modules
TypeScript's typings for some popular node.js modules
Hi, I've created a .d.ts for client-side usage of socket.io. It's very short, but it works for me.
Here's the code:
declare var io : {
connect(url: string): Socket;
}
interface Socket {
on(event: string, callback: (data: any) => void );
emit(event: string, data: any);
}
first error (and looks like the only one, subsequent error are caused by this one) is:
/typescript-node-definitions/node.d.ts(938,26): error TS1005: ',' expected.
It looks like it's missing "export function" in both line 938 and 939
tested on ts 0.9.0.1, node 0.8.11
I don't see GridFSBucket support. Is there a version that supports this?
Classic TypeScript problem here. A JavaScript function has taken advantage of dynamic typing and TypeScript can't represent it.
Parsing url normally
> require('url').parse('/?a=1')
{ ...
query: "a=1",
... }
Parse it with query parsing switched on
> require('url').parse('/?a=1', true)
{ ...
query: {a: '1'},
... }
Parse it with multiple instances of an a parameter
> require('url').parse('/?a=1&a=2', true)
{ ...
query: {a: ['1', '2']}
... }
I propose changing this field to any. It sucks but we can't do any better right now.
Maybe one day a sum type that can express this sort of thing will make its way into the language.
A pull request will be forthcoming.
q.d.ts is missing at least a few functions like Q.nfbind
.
Also, both indentation and line endings are wildly inconsistent within q.d.ts.
As per documentation:
Identical to .multi without transactions. This is recommended if you want to execute many commands at once but don't have to rely on transactions
All of these methods:
export function connect(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): void;
export function connect(port: number, host?: string, connectionListener?: Function): void;
export function connect(path: string, connectionListener?: Function): void;
export function createConnection(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): void;
export function createConnection(port: number, host?: string, connectionListener?: Function): void;
export function createConnection(path: string, connectionListener?: Function): void;
should return NodeSocket
instead of void
.
When I have this code:
/// <reference path="./node.d.ts" />
import http = module('http')
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
and try to compile it, I get:
node.d.ts(15,13) error TS2000: Duplicate identifier 'console'.
node.d.ts(314, 18) error TS4022: Type reference cannot refer to container '"child_process"'.
Is this my fault?
one error:
typescript-node-definitions/express3.d.ts(21,18): error TS1003: Identifier expected.
which is on this line:
export function (): Application;
is the function expecting a name?
tested on ts 0.9.0.1, node 0.8.11
i get these compilation errors for jquery
PATH_TO_TS_DEFS/jquery.d.ts(360,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '(handler: any) => JQuery' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(361,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '(handler: (event: any, jqXHR: any, settings: any, exception: any) => any) => JQuery' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(362,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '(handler: (event: any, jqXHR: any, settings: any, exception: any) => any) => JQuery' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(363,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '(handler: () => any) => JQuery' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(364,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '(handler: () => any) => JQuery' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(365,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '(handler: (event: any, jqXHR: any, settings: any, exception: any) => any) => JQuery' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(367,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (url: string, data?: any, complete?: any): JQuery; (eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; (handler: (eventObject: JQueryEventObject) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(369,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '() => string' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(370,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '() => any[]' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(375,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (classNames: string): JQuery; (func: (index: any, currentClass: any) => string): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(376,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (classNames: string): JQuery; (func: (index: any, currentClass: any) => string): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(379,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '(selector?: string) => JQuery' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(382,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (attributeName: string): string; (attributeName: string, value: any): JQuery; (map: { [key: string]: any; }): JQuery; (attributeName: string, func: (index: any, attr: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(383,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (attributeName: string): string; (attributeName: string, value: any): JQuery; (map: { [key: string]: any; }): JQuery; (attributeName: string, func: (index: any, attr: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(384,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (attributeName: string): string; (attributeName: string, value: any): JQuery; (map: { [key: string]: any; }): JQuery; (attributeName: string, func: (index: any, attr: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(385,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (attributeName: string): string; (attributeName: string, value: any): JQuery; (map: { [key: string]: any; }): JQuery; (attributeName: string, func: (index: any, attr: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(387,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '(className: string) => boolean' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(389,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (): string; (htmlString: string): JQuery; (htmlContent: (index: number, oldhtml: string) => string): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(390,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (): string; (htmlString: string): JQuery; (htmlContent: (index: number, oldhtml: string) => string): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(391,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (): string; (htmlString: string): JQuery; (htmlContent: (index: number, oldhtml: string) => string): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(393,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (propertyName: string): any; (propertyName: string, value: any): JQuery; (map: any): JQuery; (propertyName: string, func: (index: any, oldPropertyValue: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(394,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (propertyName: string): any; (propertyName: string, value: any): JQuery; (map: any): JQuery; (propertyName: string, func: (index: any, oldPropertyValue: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(395,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (propertyName: string): any; (propertyName: string, value: any): JQuery; (map: any): JQuery; (propertyName: string, func: (index: any, oldPropertyValue: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(396,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (propertyName: string): any; (propertyName: string, value: any): JQuery; (map: any): JQuery; (propertyName: string, func: (index: any, oldPropertyValue: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(398,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '(attributeName: any) => JQuery' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(400,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (className?: any): JQuery; (func: (index: any, cls: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(401,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (className?: any): JQuery; (func: (index: any, cls: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(403,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '(propertyName: any) => JQuery' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(405,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (className: any, swtch?: boolean): JQuery; (swtch?: boolean): JQuery; (func: (index: any, cls: any, swtch: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(406,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (className: any, swtch?: boolean): JQuery; (swtch?: boolean): JQuery; (func: (index: any, cls: any, swtch: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(407,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (className: any, swtch?: boolean): JQuery; (swtch?: boolean): JQuery; (func: (index: any, cls: any, swtch: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(409,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (): any; (value: string[]): JQuery; (value: string): JQuery; (value: number): JQuery; (func: (index: any, value: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(410,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (): any; (value: string[]): JQuery; (value: string): JQuery; (value: number): JQuery; (func: (index: any, value: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(411,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (): any; (value: string[]): JQuery; (value: string): JQuery; (value: number): JQuery; (func: (index: any, value: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(412,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (): any; (value: string[]): JQuery; (value: string): JQuery; (value: number): JQuery; (func: (index: any, value: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(413,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (): any; (value: string[]): JQuery; (value: string): JQuery; (value: number): JQuery; (func: (index: any, value: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(418,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (propertyName: string): string; (propertyNames: string[]): string; (properties: any): JQuery; (propertyName: string, value: any): JQuery; (propertyName: any, value: any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(419,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (propertyName: string): string; (propertyNames: string[]): string; (properties: any): JQuery; (propertyName: string, value: any): JQuery; (propertyName: any, value: any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(420,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (propertyName: string): string; (propertyNames: string[]): string; (properties: any): JQuery; (propertyName: string, value: any): JQuery; (propertyName: any, value: any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(421,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (propertyName: string): string; (propertyNames: string[]): string; (properties: any): JQuery; (propertyName: string, value: any): JQuery; (propertyName: any, value: any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(422,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (propertyName: string): string; (propertyNames: string[]): string; (properties: any): JQuery; (propertyName: string, value: any): JQuery; (propertyName: any, value: any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(424,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (): number; (value: number): JQuery; (value: string): JQuery; (func: (index: any, height: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(425,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (): number; (value: number): JQuery; (value: string): JQuery; (func: (index: any, height: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(426,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (): number; (value: number): JQuery; (value: string): JQuery; (func: (index: any, height: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
PATH_TO_TS_DEFS/jquery.d.ts(427,5): error TS2172: All named properties must be subtypes of string indexer type 'HTMLElement':
Type '{ (): number; (value: number): JQuery; (value: string): JQuery; (func: (index: any, height: any) => any): JQuery; }' is missing property 'onmouseleave' from type 'HTMLElement'.
Hi,
the fs-extra's copy and copySync functions support options parameter that is necessary while keeping the target file's time stamps after coping.
'''
copy(src, dest, [options], callback)
Copy a file or directory. The directory can have contents. Like cp -r.
Options:
clobber (boolean): overwrite existing file or directory
preserveTimestamps (boolean): will set last modification and access times to the ones of the original source files, default is false.
filter: Function or RegExp to filter copied files. If function, return true to include, false to exclude. If RegExp, same as function, where filter is filter.test.
'''
Could someone help to add this function?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.