- 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
- 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
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
}
}
```
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.
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`.
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.
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.