Welcome! Log In Create A New Profile

Advanced

[njs] Types: fixed index types in modules.

Dmitry Volyntsev
October 29, 2020 09:02AM
details: https://hg.nginx.org/njs/rev/3cc202e562e4
branches:
changeset: 1553:3cc202e562e4
user: Jakub Jirutka <jakub@jirutka.cz>
date: Mon Oct 19 23:18:22 2020 +0200
description:
Types: fixed index types in modules.

Fixes the following type errors:
Property ''xxx'' of type 'NjsByteString | undefined' is not
assignable to string index type 'NjsStringLike'.ts(2411)

While string index signatures are a powerful way to describe the
"dictionary" pattern, they also enforce that all properties match
their return type.

diffstat:

ts/ngx_http_js_module.d.ts | 6 +++---
ts/ngx_stream_js_module.d.ts | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)

diffs (42 lines):

diff -r 862ff6f2c684 -r 3cc202e562e4 ts/ngx_http_js_module.d.ts
--- a/ts/ngx_http_js_module.d.ts Sat Oct 24 23:59:18 2020 +0200
+++ b/ts/ngx_http_js_module.d.ts Mon Oct 19 23:18:22 2020 +0200
@@ -39,7 +39,7 @@ interface NginxHeadersIn {
readonly 'Warning'?: NjsByteString;
readonly 'X-Forwarded-For'?: NjsByteString;

- readonly [prop: string]: NjsByteString;
+ readonly [prop: string]: NjsByteString | undefined;
}

interface NginxHeadersOut {
@@ -76,7 +76,7 @@ interface NginxHeadersOut {

'Set-Cookie'?: NjsStringLike[];

- [prop: string]: NjsStringLike | NjsStringLike[];
+ [prop: string]: NjsStringLike | NjsStringLike[] | undefined;
}

interface NginxVariables {
@@ -229,7 +229,7 @@ interface NginxVariables {
readonly 'upstream_trailer_'?: NjsByteString;
readonly 'uri'?: NjsByteString;

- [prop: string]: NjsStringLike;
+ [prop: string]: NjsStringLike | undefined;
}

interface NginxSubrequestOptions {
diff -r 862ff6f2c684 -r 3cc202e562e4 ts/ngx_stream_js_module.d.ts
--- a/ts/ngx_stream_js_module.d.ts Sat Oct 24 23:59:18 2020 +0200
+++ b/ts/ngx_stream_js_module.d.ts Mon Oct 19 23:18:22 2020 +0200
@@ -66,7 +66,7 @@ interface NginxStreamVariables {
readonly 'time_iso8601'?: NjsByteString;
readonly 'time_local'?: NjsByteString;

- [prop: string]: NjsByteString;
+ [prop: string]: NjsByteString | undefined;
}

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

[njs] Types: fixed index types in modules.

Dmitry Volyntsev 135 October 29, 2020 09:02AM



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

Online Users

Guests: 82
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready