]> git.kaiwu.me - njs.git/commitdiff
Types: fixed index types in modules.
authorJakub Jirutka <jakub@jirutka.cz>
Mon, 19 Oct 2020 21:18:22 +0000 (23:18 +0200)
committerJakub Jirutka <jakub@jirutka.cz>
Mon, 19 Oct 2020 21:18:22 +0000 (23:18 +0200)
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.

ts/ngx_http_js_module.d.ts
ts/ngx_stream_js_module.d.ts

index d29b1385c8a47dcec2bb36ad9b8bbfdc297562c2..0440b7f4f325a2b15c6b4a387dd4be52ef57ecd6 100644 (file)
@@ -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 {
index 47799ba2395b02ed05f35bfa4bfb73d9da482cd7..67e24dfa7853e85c2aaf9726a1dc93fb5114ffbb 100644 (file)
@@ -66,7 +66,7 @@ interface NginxStreamVariables {
     readonly 'time_iso8601'?: NjsByteString;
     readonly 'time_local'?: NjsByteString;
 
-    [prop: string]: NjsByteString;
+    [prop: string]: NjsByteString | undefined;
 }
 
 interface NginxStreamCallbackFlags {