Commit Graph

88 Commits

Author SHA1 Message Date
Paul Loyd
25a3c76b44 node: move Node* to NodeJS module 2014-04-28 18:32:37 +02:00
Paul Loyd
c52e7bdf63 node: now modules depend on stream.* when possible 2014-04-28 18:32:37 +02:00
Paul Loyd
d100d104c6 node: now modules depend on events.EventEmitter, not NodeEventEmitter 2014-04-28 18:32:36 +02:00
Paul Loyd
c40cc2df89 node: rename ErrnoException to NodeErrnoException 2014-04-28 18:32:36 +02:00
Paul Loyd
1d451a05e1 node: NodeBuffer -> Buffer. Mark NodeBuffer as deprecated 2014-04-28 18:32:36 +02:00
Robert Knight
1c5ed81577 Export Node functions for creating decipher correctly
* createDecipher() and createDecipheriv() are functions
   in the crypto module, not methods of the Cipher interface.

 * Add pbkdf2Sync() decl
2014-04-18 21:18:09 +01:00
John Purcell
325d35130f Merge branch master into listen_bug 2014-04-01 08:21:11 -04:00
Masahiro Wakame
a4ceaf4d42 Merge pull request #1880 from jpmoodlerooms/node_crypto
Update crypto.Hmac.update and crypto.Hmac.digest methods to the correct signature
2014-04-01 10:27:08 +09:00
Bart van der Schoor
2fdba9cbbe add hash/path to both Url & UrlOptions 2014-03-31 21:21:42 +02:00
Bart van der Schoor
12766b5357 added hash & path to node's UrlOptions 2014-03-31 18:22:26 +02:00
Bart van der Schoor
d70401ed4d fixed realpathsync again 2014-03-31 17:33:29 +02:00
Bart van der Schoor
c45713047f Revert "Merge pull request #1931 from yortus/node-express-referenceable-types"
This reverts commit 0bfcda81b4, reversing
changes made to 2c52e529f9.
2014-03-31 17:31:31 +02:00
vvakame
2aabba9905 Improvement node.d.ts typings 2014-04-01 00:04:35 +09:00
Troy Gerwien
cbd13655e5 add hash to NodeJs.Url.Url 2014-03-31 22:20:09 +08:00
yortus
69bd32f4c1 pure internal modules + external shim
- The top-level modules Express and NodeJs are now 'pure' ie
non-instantiated, due to removal of all vars, functions, and classes
- Where the above change breaks existing typings which access types via
external module references, a shim has been added to make this continue
working unchanged
- A single namespace _ExternalShim_ is added but this can be reused
across all typings that need shimming
2014-03-31 15:18:53 +08:00
yortus
6a320ef211 EventEmitter can be new()d 2014-03-31 11:10:37 +08:00
Troy Gerwien
c2b67de6aa Fixed assert, added comments, rechecked all
- Added comments explaining the rationale/method of exposing into both
'type' and 'member' declaration spaces (see TLR 2.3) with example
- Made the pattern consistent in both definition files
- Fixed "assert" by adding 'export function Assert...'
- Triple-checked with DT tests and additional tests
2014-03-30 21:56:50 +08:00
Troy Gerwien
6f472b8f09 WIP: all passing (bar assert) but needs more...
Need to remove superfluous typings - eg NodeJs.QueryString.escape should
not be valid
2014-03-30 10:05:57 +08:00
Troy Gerwien
368266b684 var-interface-module pattern now consistent
Everything (in both node and express) now follows the pattern:
```
declare module "external-name" {
import _ = InternalName.InnerName;
export = _;
}
declare module InternalName {
export var InnerName: InnerName;
export interface InnerName {
// functions and vars in here
}
export module InnerName {
// Must be non-instantiated - so only interfaces and modules in here
}
}

```
2014-03-29 21:21:41 +08:00
Troy Gerwien
a7829a1fd9 referenceable types throughout node and express
All node modules and classes can be referenced by type name. External
module support remains unchanged, but now static type information is
available for all node modules and types without needing to go through
the external module definitions.

Similar for express.
2014-03-28 22:32:20 +08:00
John Purcell
cb01abe1b2 Return correct type from .listen() and .close(), expose .address() on http.Server 2014-03-26 14:54:22 -04:00
troy_paypac
1fd18add08 internal module defns for node and express 2014-03-26 15:04:06 +08:00
Paul Loyd
0cdeaaa3a7 node: rename http.NodeAgent to http.Agent and net.NodeSocket to net.Socket 2014-03-22 21:29:50 +04:00
John Purcell
941d790d6f Update crypto.Hmac.update and crypto.Hmac.digest methods to the correct signature 2014-03-19 16:53:31 -04:00
Paul Loyd
e3b9fef277 node: fix signatures of readFile* 2014-03-17 14:55:17 +04:00
vvakame
adb74d94ce Suppress warnings aboud node.d.ts 2014-02-26 09:54:15 +09:00
John Vilk
87ac1b3421 [Node] Updating stream interfaces and removing redundant interfaces.
We duplicated the EventEmitter and Stream interfaces in the "event" module, so I removed the redundant interface definitions.

I have updated the ReadableStream/WritableStream interfaces in accordance with the current documentation:
http://nodejs.org/api/stream.html

I added class definitions for Writable/Transform/Duplex/PassThrough in 'event'. These classes are described in the following Node documentation:
http://nodejs.org/api/stream.html#stream_api_for_stream_implementors

As a result of these changes, I needed to slightly alter other typings to refer to the new interface name. This was unavoidable; I had to rename the `EventEmitter` interface to `NodeEventEmitter` to avoid clashing with the `events.EventEmitter` class that implements `NodeEventEmitter`.
2014-02-05 14:28:10 -05:00
John Vilk
4f20894ed5 [Node] Fixing WritableStream.write and WritableStream.end.
Documentation for WritableStream.write:
http://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback

There's no 'fd' argument; that might have been a typo.

You can call `write` in the following ways:
* write(data: Buffer)
* write(data: Buffer, cb: Function)
* write(data: String)
* write(data: String, cb: Function)
* write(data: String, encoding: String)
* write(data: String, encoding: String, cb: Function)

The same goes to `end`, except `end` can be called with no arguments, too.
2014-01-30 21:18:22 -05:00
Bartvds
5d95684e19 added/fixed headers k-n
https://github.com/borisyankov/DefinitelyTyped/issues/1570
2014-01-24 01:19:01 +01:00
John Vilk
cddd0b7aab [Node] Node attaches errno information to some exceptions.
This is valuable information for Node applications that need to figure out why a particular system call failed.

Note that errno can either be a string or a number, which is why I have typed it as 'any'.

While this is undocumented, it is tested:
Code property: https://github.com/joyent/node/blob/v0.10.23-release/test/simple/test-fs-open.js#L34
Errno property [string]: https://github.com/joyent/node/blob/v0.10.23-release/test/internet/test-dns.js#L148
Errno property [number]: https://github.com/joyent/node/blob/v0.10.23-release/test/simple/test-domain-implicit-fs.js#L43
Syscall property: https://github.com/joyent/node/blob/v0.10.23-release/test/simple/test-stdout-close-catch.js#L38
Path property (I can’t find a test, but many examples have this line): https://github.com/joyent/node/blob/v0.10.23-release/deps/npm/node_modules/fstream-npm/example/bundle.js#L6

..and well supported in the code for all platforms (this is where I got the name 'ErrnoException' from):
*nix: https://github.com/joyent/node/blob/v0.10.23-release/src/node.cc#L719
Windows: https://github.com/joyent/node/blob/v0.10.23-release/src/node.cc#L856

Unfortunately, while every errno exception is guaranteed to have the ‘errno’ and ‘code’ properties (see the logic in the source code in node.cc), there is no hard guarantee that particular library functions will always pass an ErrnoException to the callback. I cannot find a counterexample at this moment, though. Since we can’t have union types in TypeScript, I simply made all of the properties on ErrnoException optional as a compromise.

I am only adding modifications to the fs module, which definitely throws ErrnoExceptions. But according to the examples above, other modules (e.g. dns) also pass errno information back to applications. People familiar with those other modules can update their typings to reference this interface when applicable; I lack the experience with those modules to update their typings.

Further proof:
```javascript
$ node
> var fs = require('fs');
undefined
> fs.open('doesntexistlol', 'r', function(e) { console.log(Object.keys(e)); console.log(e.code); console.log(e.errno); console.log(e.path); });
undefined
> [ 'errno', 'code', 'path' ]
ENOENT
34
doesntexistlol
```
2013-12-17 16:36:08 -05:00
John Vilk
f1c040b378 [Node] Removing incorrect typing for buffer.INSPECT_MAX_BYTES.
From http://nodejs.org/api/buffer.html#buffer_buffer_inspect_max_bytes:

"...this is a property on the buffer module returned by require('buffer'), not on the Buffer global, or a buffer instance."

The Node typings do not have a notion of a buffer module, and introducing one would be more work than might be useful. It contains a reference to `Buffer` and `SlowBuffer`, which are currently defined as variables in the typings. I believe I would need
 to redefine these in the module definition.

If anyone has any ideas for how to efficiently restructure this, let me know.
2013-12-12 14:41:23 -05:00
Paul Loyd
20065c967a Rename Timer to NodeTimer 2013-12-08 12:44:52 +04:00
Mike H. Hawley
8f9ac50d4b Fix fs interface 2013-12-06 17:42:57 +03:00
Nick Howes
073000951d Update util.inspect API.
Latest API has an options object as the second parameter
instead of separate parameters. The old API is still supported
so have added the new signature as an overload.

Updated node-tests.ts
2013-12-05 12:45:17 +00:00
Basarat Ali Syed
9f3be188ac Merge pull request #1368 from halfninja/halfninja-node-url
Fix Node url.format() param type
2013-12-03 13:02:58 -08:00
Nick Howes
04ddf4ba31 Fix url.format() param type. 2013-12-03 13:20:56 +00:00
Paul Loyd
1e3efb6e24 Add worker's "send" method to NodeProcess 2013-11-25 23:57:04 +03:00
Basarat Ali Syed
d7968354c2 Merge pull request #1327 from ctaggart/nodejsBugStream
node bug fix, make ReadableStream the same as stream.ReadableStream
2013-11-24 14:24:04 -08:00
Cameron Taggart
ee21e8494b makes ReadableStream the same as stream.ReadableStream by applying the pipe change
from commit d0139df89d
2013-11-24 15:36:02 -06:00
Paul Loyd
70a2f13438 Fix assert module 2013-11-24 18:00:30 +04:00
Paul Loyd
f2a4348c20 Correct domain module 2013-11-24 17:38:56 +04:00
Paul Loyd
c3541fe0b9 Correct assert module 2013-11-24 17:38:56 +04:00
Chris Cowan
5b9620556e Fixes for node definitions.
setTimeout, setInterval, setImmediate are fixed to accept more
arguments.

setTimeout, setInterval, clearTimeout, clearInterval are changed to
return and accept objects of the new Timer interface, which exposes the
ref() and unref() methods.

fs.readFileSync is changed so that it returns a string if it is passed
an options parameter with an "encoding" property, and returns a
NodeBuffer otherwise.

fs.watchFile and fs.unwatchFile listener parameters are fixed. listener
is a callback with two parameters, not an object with two properties.

fs.watch is fixed so a listener parameter can be given without an
options parameter.

crypto.randomBytes is fixed so that it can be called synchronously,
returning a NodeBuffer.

crypto.pseudoRandomBytes is added.
2013-11-23 16:31:40 -06:00
Paul Loyd
5ddb5b9c3e Correct cluster and add events.EventEmitter.listenerCount 2013-11-20 18:12:31 +03:00
Paul Loyd
1b027b44e1 Update node.d.ts
Update signature of EventEmitter#emit
2013-11-15 20:57:49 +03:00
John Vilk
b6f524aa2f Buffer.copy() returns the number of bytes copied.
I know it's not mentioned in the documentation, but the Node unit tests check for this behavior, e.g. https://github.com/joyent/node/blob/master/test/simple/test-buffer.js#L54
2013-11-03 04:17:31 -05:00
Duncan Mak
d9735793e9 Update signatures for EventEmitter.
Allow for method chaining in addListener/removeListener, on/once,
and removeAllListeners.

Fix return type for 'emit'.

This patch mirrors the changes made to the API docs in this commit:
41cbdc5e64
2013-10-22 11:22:35 -04:00
John Vilk
baa367d1b3 stat/lstat/fstat are asynchronous and return void.
Also tidying up a few callback signatures for fun.
2013-09-28 17:48:26 -04:00
John Vilk
0b306aaef6 'mode' can be a number or a string.
I realize this could be considered pedantic, but the typings do not even consistently use one or the other. Previously, certain functions assumed string, others assumed number. This way, you can use either.
2013-09-27 15:50:03 -04:00
John Vilk
666cd33fe8 In many fs functions, mode is optional, which means that the argument that takes its slot becomes the callback.
Adding alternative definitions to account for this.
2013-09-27 15:43:28 -04:00