Skip to content

Commit 042dd4f

Browse files
cyberbobsBoris Moiseev
andauthored
🤖 Merge PR DefinitelyTyped#73555 Add type definitions for emailjs-utf7 by @cyberbobs
Co-authored-by: Boris Moiseev <[email protected]>
1 parent e859ad7 commit 042dd4f

File tree

5 files changed

+117
-0
lines changed

5 files changed

+117
-0
lines changed

types/emailjs-utf7/.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
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { decode, encode, encodeAll, imapDecode, imapEncode } from "emailjs-utf7";
2+
3+
// @ts-expect-error
4+
encode();
5+
encode("testing", "testmask"); // $ExpectType string
6+
encode("testing"); // $ExpectType string
7+
// @ts-expect-error
8+
encode(5);
9+
// @ts-expect-error
10+
encode(true);
11+
12+
// @ts-expect-error
13+
encodeAll();
14+
encodeAll("testing"); // $ExpectType string
15+
// @ts-expect-error
16+
encodeAll(5);
17+
// @ts-expect-error
18+
encodeAll(true);
19+
20+
// @ts-expect-error
21+
decode();
22+
decode("BCgEMAQxBDsEPgQ9BEs"); // $ExpectType string
23+
// @ts-expect-error
24+
decode(5);
25+
// @ts-expect-error
26+
decode(true);
27+
28+
// @ts-expect-error
29+
imapEncode();
30+
imapEncode("testing"); // $ExpectType string
31+
// @ts-expect-error
32+
imapEncode(5);
33+
// @ts-expect-error
34+
imapEncode(true);
35+
36+
// @ts-expect-error
37+
imapDecode();
38+
imapDecode("&BCgEMAQxBDsEPgQ9BEs-"); // $ExpectType string
39+
// @ts-expect-error
40+
imapDecode(5);
41+
// @ts-expect-error
42+
imapDecode(true);

types/emailjs-utf7/index.d.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Encodes string to UTF-7, see RFC 2152
3+
* @param str String to encode
4+
* @param mask (optional) Characters to encode, defaults to RFC 2152 Set D
5+
*/
6+
export function encode(str: string, mask?: string): string;
7+
8+
/**
9+
* Encodes string to UTF-7 with all optionals, see RFC 2152
10+
* @param str String to encode
11+
*/
12+
export function encodeAll(str: string): string;
13+
14+
/**
15+
* Decodes UTF-7 string, see RFC 2152
16+
* @param str String to decode
17+
*/
18+
export function decode(str: string): string;
19+
20+
/**
21+
* Encodes string to UTF-7 with all optionals, see RFC 3501
22+
*
23+
* All printable ASCII chars except for & must be represented by themselves.
24+
* We replace subsequent non-representable chars with their escape sequence.
25+
*
26+
* @param str String to encode
27+
*/
28+
export function imapEncode(str: string): string;
29+
30+
/**
31+
* Decodes UTF-7 string, see RFC 3501
32+
* @param str String to decode
33+
*/
34+
export function imapDecode(str: string): string;

types/emailjs-utf7/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"private": true,
3+
"name": "@types/emailjs-utf7",
4+
"version": "4.0.9999",
5+
"projects": [
6+
"https://github.com/emailjs/emailjs-utf7"
7+
],
8+
"devDependencies": {
9+
"@types/emailjs-utf7": "workspace:."
10+
},
11+
"owners": [
12+
{
13+
"name": "Boris Moiseev",
14+
"githubUsername": "cyberbobs"
15+
}
16+
]
17+
}

types/emailjs-utf7/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+
"emailjs-utf7-tests.ts"
18+
]
19+
}

0 commit comments

Comments
 (0)