Welcome! Log In Create A New Profile

Advanced

[njs] Fixed TypeScript description for NjsByteString type.

Dmitry Volyntsev
July 06, 2020 02:40PM
details: https://hg.nginx.org/njs/rev/f2e8486b3b6d
branches:
changeset: 1449:f2e8486b3b6d
user: Artem S. Povalyukhin <artem.povaluhin@gmail.com>
date: Sat Jun 27 19:26:41 2020 +0300
description:
Fixed TypeScript description for NjsByteString type.

NjsByteString was declared as it has no relation to string primitive type.
This causes a problem when a variable of type NjsByteString is passed into
built-in functions expecting string type.

The issue was introduced in 8f3ef384f69e.

diffstat:

src/ts/njs_core.d.ts | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)

diffs (36 lines):

diff -r 1c729f765cfb -r f2e8486b3b6d src/ts/njs_core.d.ts
--- a/src/ts/njs_core.d.ts Thu Jul 02 14:00:16 2020 +0000
+++ b/src/ts/njs_core.d.ts Sat Jun 27 19:26:41 2020 +0300
@@ -14,14 +14,14 @@ interface String {
* Serializes a Unicode string with code points up to 255
* into a byte string, otherwise, null is returned.
*/
- toBytes(start?: number, end?: number): NjsByteString;
+ toBytes(start?: number, end?: number): NjsByteString | null;
/**
* Serializes a Unicode string to a byte string using UTF8 encoding.
*/
toUTF8(start?: number, end?: number): NjsByteString;
}

-interface NjsByteString extends String {
+type NjsByteString = string & {
/**
* Returns a new Unicode string from a byte string where each byte is replaced
* with a corresponding Unicode code point.
@@ -31,12 +31,12 @@ interface NjsByteString extends String {
* Converts a byte string containing a valid UTF8 string into a Unicode string,
* otherwise null is returned.
*/
- fromUTF8(start?: number, end?: number): string;
+ fromUTF8(start?: number, end?: number): string | null;
/**
* Encodes a byte string to hex, base64, or base64url.
*/
- toString(encoding?: "hex" | "base64" | "base64url"): string;
-}
+ toString(encoding: "hex" | "base64" | "base64url"): string;
+};

type NjsStringLike = string | NjsByteString;

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed TypeScript description for NjsByteString type.

Dmitry Volyntsev 211 July 06, 2020 02:40PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 195
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready