Git Product home page Git Product logo

typescript-node-definitions's Introduction

This project aims to contain several definitions of common node.js libraries for TypeScript language in order to have autocomplete support.

It would be great if the creators of node modules, include definition files directly on their projects. In the meanwhile this project will do the job.

Initial definition files are from the TypeScript project "samples" folder, that can be found here: https://typescript.codeplex.com/SourceControl/BrowseLatest

You can perform pull requests improving definitions or adding new ones. I will add them ASAP.

In order to be able to use it easily, you can create a git submodule for your project adding this in the .gitmodules file:

[submodule "typescript-node-definitions"]
	path = typescript-node-definitions
	url = git://github.com/soywiz/typescript-node-definitions.git

Also you can create a "app.d.ts" file or similar including all the definitions file that are you using in your project:

///<reference path='typescript-node-definitions/node.d.ts'/>
///<reference path='typescript-node-definitions/mongodb.d.ts'/>
///<reference path='typescript-node-definitions/express3.d.ts'/>
///<reference path='typescript-node-definitions/consolidate.d.ts'/>

typescript-node-definitions's People

Contributors

ameenahmed avatar bardt avatar bibbychung avatar bjouhier avatar bobappleyard avatar bonnici avatar dasa avatar dbrattli avatar farokhcpu avatar halfninja avatar jedigo avatar macil avatar midknight41 avatar soywiz avatar sudsy avatar tkafka avatar tyoverby avatar varju avatar zikifer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typescript-node-definitions's Issues

options parameter missing for copy and copySync functions in fs-extra.d.ts

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?

jquery compilation errors

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'.

Socket.io client-side d.ts

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);
}

url.Url.query is many-typed

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.

express3.d.ts is failing to compile

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

nodejs net connect* methods return a socket, not void

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.

Duplicate identifier console

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?

node.d.ts failing to compile

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

q.d.ts missing Q.nfbind

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.