From f7c79778d94ae46edd1adeffe7916e843088805e Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 29 Oct 2018 11:56:25 -0700 Subject: [PATCH] plist: Support building from ReadonlyArray (#30119) --- types/plist/index.d.ts | 4 ++-- types/plist/plist-tests.ts | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/types/plist/index.d.ts b/types/plist/index.d.ts index b7064e55a3..f97b267df4 100644 --- a/types/plist/index.d.ts +++ b/types/plist/index.d.ts @@ -20,9 +20,9 @@ export type PlistValue = string | number | boolean | Date | Buffer | PlistObject | PlistArray; export interface PlistObject { - [x: string]: PlistValue; + readonly [x: string]: PlistValue; } -export interface PlistArray extends Array { } +export interface PlistArray extends ReadonlyArray { } // PlistBuildOptions // The instance of this type is passed to 'xmlbuilder' module as it is. diff --git a/types/plist/plist-tests.ts b/types/plist/plist-tests.ts index a94cb4cf71..00dc33b56c 100644 --- a/types/plist/plist-tests.ts +++ b/types/plist/plist-tests.ts @@ -79,3 +79,10 @@ console.log(plistString1); const plistString2 = plist.build(plistValue2, {pretty: false}); console.log(plistString2); + +function f(a: ReadonlyArray) { + plist.build(a); +} + +// $ExpectError +plist.build(() => 0);