Skip to content

Commit 768defe

Browse files
feat: add type kafkajs-snappy (DefinitelyTyped#71905)
Co-authored-by: Matteo Di Sabatino <[email protected]>
1 parent 5d284d8 commit 768defe

File tree

5 files changed

+70
-0
lines changed

5 files changed

+70
-0
lines changed

types/kafkajs-snappy/.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!**/*.d.ts
3+
!**/*.d.cts
4+
!**/*.d.mts
5+
!**/*.d.*.ts

types/kafkajs-snappy/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference types="node" />
2+
interface KafkaJSSnappyCodec {
3+
compress: (encoder: { buffer: Buffer }) => Promise<Buffer>;
4+
decompress: (buffer: Buffer) => Promise<Buffer>;
5+
}
6+
7+
declare function KafkaJSSnappy(): KafkaJSSnappyCodec;
8+
9+
export = KafkaJSSnappy;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import KafkaJSSnappy from "kafkajs-snappy";
2+
3+
const codec = KafkaJSSnappy();
4+
5+
const buffer = Buffer.alloc(100);
6+
7+
// @ts-expect-error Missing arg
8+
codec.compress();
9+
// @ts-expect-error Invalid arg
10+
codec.compress([]);
11+
codec.compress({ buffer: buffer }); // $ExpectType Promise<Buffer> || Promise<Buffer<ArrayBufferLike>>
12+
13+
// @ts-expect-error Missing arg
14+
codec.decompress();
15+
// @ts-expect-error Invalid arg
16+
codec.decompress([]);
17+
codec.decompress(buffer); // $ExpectType Promise<Buffer> || Promise<Buffer<ArrayBufferLike>>

types/kafkajs-snappy/package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"private": true,
3+
"name": "@types/kafkajs-snappy",
4+
"version": "1.0.9999",
5+
"projects": [
6+
"https://github.com/tulios/kafkajs-snappy"
7+
],
8+
"dependencies": {
9+
"@types/node": "*"
10+
},
11+
"devDependencies": {
12+
"@types/kafkajs-snappy": "workspace:."
13+
},
14+
"owners": [
15+
{
16+
"name": "Matteo Di Sabatino",
17+
"githubUsername": "matteodisabatino"
18+
}
19+
]
20+
}

types/kafkajs-snappy/tsconfig.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"module": "node16",
4+
"lib": [
5+
"es6"
6+
],
7+
"noImplicitAny": true,
8+
"noImplicitThis": true,
9+
"strictFunctionTypes": true,
10+
"strictNullChecks": true,
11+
"types": [],
12+
"noEmit": true,
13+
"forceConsistentCasingInFileNames": true
14+
},
15+
"files": [
16+
"index.d.ts",
17+
"kafkajs-snappy-tests.ts"
18+
]
19+
}

0 commit comments

Comments
 (0)