mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* [node]: Make stream destroy method signatures match The "destroy" option when creating streams has the same signature as the _destroy method on the stream: a function accepting an optional error and a callback which also takes an optional error. * Fix tests affected by the change in stream definitions
45 lines
721 B
TypeScript
45 lines
721 B
TypeScript
import { decode, encode, Stream } from 'amp';
|
|
|
|
// $ExpectType Buffer[]
|
|
decode(new Buffer('something'));
|
|
|
|
// $ExpectType Buffer
|
|
encode([new Buffer('something'), new Buffer('something')]);
|
|
|
|
// $ExpectError
|
|
decode('');
|
|
|
|
// $ExpectError
|
|
decode(1);
|
|
|
|
// $ExpectError
|
|
decode();
|
|
|
|
// $ExpectError
|
|
encode('');
|
|
|
|
// $ExpectError
|
|
encode(1);
|
|
|
|
// $ExpectError
|
|
encode();
|
|
|
|
// $ExpectType Stream
|
|
new Stream({});
|
|
|
|
// $ExpectType Stream
|
|
new Stream({
|
|
highWaterMark: 1,
|
|
decodeStrings: true,
|
|
objectMode: true,
|
|
destroy: (error: Error | null) => {
|
|
return 'handle error';
|
|
},
|
|
final: (callback: (error?: Error) => void) => {
|
|
// do nothing
|
|
}
|
|
});
|
|
|
|
// $ExpectError
|
|
new Stream({somethingNoneExisting: true});
|