Skip to content

Commit aa92fc0

Browse files
authored
🤖 Merge PR DefinitelyTyped#71614 fix(tr46): fix return type of exported functions by @hkleungai
1 parent e435aee commit aa92fc0

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

‎types/tr46/index.d.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
/**
22
* Converts a string of Unicode symbols to a case-folded Punycode string of ASCII symbols.
33
*/
4-
export function toASCII(domainName: string, options?: ToASCIIOptions): string;
4+
export function toASCII(
5+
domainName: string,
6+
options?: ToASCIIOptions,
7+
): string | null;
58

69
/**
710
* Converts a case-folded Punycode string of ASCII symbols to a string of Unicode symbols.
811
*/
9-
export function toUnicode(domainName: string, options?: Options): string;
12+
export function toUnicode(
13+
domainName: string,
14+
options?: Options,
15+
): { domain: string; error: boolean };
1016

1117
export interface Options {
1218
/**

‎types/tr46/tr46-tests.ts‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ import { Options, toASCII, ToASCIIOptions, toUnicode } from "tr46";
44
type O = Options;
55
type TAO = ToASCIIOptions;
66

7-
toASCII("foo.bar"); // $ExpectType string
8-
toASCII("foo.bar", { checkBidi: true }); // $ExpectType string
9-
toASCII("foo.bar", { checkHyphens: true }); // $ExpectType string
10-
toASCII("foo.bar", { checkJoiners: true }); // $ExpectType string
11-
toASCII("foo.bar", { ignoreInvalidPunycode: true }); // $ExpectType string
12-
toASCII("foo.bar", { transitionalProcessing: true }); // $ExpectType string
13-
toASCII("foo.bar", { useSTD3ASCIIRules: true }); // $ExpectType string
14-
toASCII("foo.bar", { verifyDNSLength: true }); // $ExpectType string
7+
toASCII("foo.bar"); // $ExpectType string | null
8+
toASCII("foo.bar", { checkBidi: true }); // $ExpectType string | null
9+
toASCII("foo.bar", { checkHyphens: true }); // $ExpectType string | null
10+
toASCII("foo.bar", { checkJoiners: true }); // $ExpectType string | null
11+
toASCII("foo.bar", { ignoreInvalidPunycode: true }); // $ExpectType string | null
12+
toASCII("foo.bar", { transitionalProcessing: true }); // $ExpectType string | null
13+
toASCII("foo.bar", { useSTD3ASCIIRules: true }); // $ExpectType string | null
14+
toASCII("foo.bar", { verifyDNSLength: true }); // $ExpectType string | null
1515
// @ts-expect-error
1616
toASCII("foo.bar", { foo: true });
1717

18-
toUnicode("foo.bar"); // $ExpectType string
19-
toUnicode("foo.bar", { checkBidi: true }); // $ExpectType string
20-
toUnicode("foo.bar", { checkHyphens: true }); // $ExpectType string
21-
toUnicode("foo.bar", { checkJoiners: true }); // $ExpectType string
22-
toUnicode("foo.bar", { ignoreInvalidPunycode: true }); // $ExpectType string
23-
toUnicode("foo.bar", { transitionalProcessing: true }); // $ExpectType string
24-
toUnicode("foo.bar", { useSTD3ASCIIRules: true }); // $ExpectType string
18+
toUnicode("foo.bar"); // $ExpectType { domain: string, error: boolean }
19+
toUnicode("foo.bar", { checkBidi: true }); // $ExpectType { domain: string, error: boolean }
20+
toUnicode("foo.bar", { checkHyphens: true }); // $ExpectType { domain: string, error: boolean }
21+
toUnicode("foo.bar", { checkJoiners: true }); // $ExpectType { domain: string, error: boolean }
22+
toUnicode("foo.bar", { ignoreInvalidPunycode: true }); // $ExpectType { domain: string, error: boolean }
23+
toUnicode("foo.bar", { transitionalProcessing: true }); // $ExpectType { domain: string, error: boolean }
24+
toUnicode("foo.bar", { useSTD3ASCIIRules: true }); // $ExpectType { domain: string, error: boolean }
2525
// @ts-expect-error
2626
toUnicode("foo.bar", { verifyDNSLength: true });
2727
// @ts-expect-error

0 commit comments

Comments
 (0)