mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-20 12:46:36 +08:00
types for amp 0.3
This commit is contained in:
44
types/amp/amp-tests.ts
Normal file
44
types/amp/amp-tests.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
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) => {
|
||||
return 'handle error';
|
||||
},
|
||||
final: (callback: (error?: Error) => void) => {
|
||||
// do nothing
|
||||
}
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
new Stream({somethingNoneExisting: true});
|
||||
19
types/amp/index.d.ts
vendored
Normal file
19
types/amp/index.d.ts
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// Type definitions for amp 0.3
|
||||
// Project: https://github.com/visionmedia/node-amp
|
||||
// Definitions by: Vilim Stubičan <https://github.com/jewbre>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as stream from 'stream';
|
||||
|
||||
export function decode(buf: Buffer): Buffer[];
|
||||
|
||||
export function encode(args: Buffer[]): Buffer;
|
||||
|
||||
export class Stream extends stream.Writable {
|
||||
constructor(opts: stream.WritableOptions);
|
||||
|
||||
_write(chunk: any, encoding: string, fn: () => void): void;
|
||||
}
|
||||
23
types/amp/tsconfig.json
Normal file
23
types/amp/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"amp-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/amp/tslint.json
Normal file
1
types/amp/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user