From 048300491777c030ab12abea85e92a6896f71c0f Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 4 Aug 2021 12:05:35 +0300 Subject: [PATCH] fix(utils): support old TypeScript versions --- .changeset/old-forks-think.md | 5 +++++ packages/utils/src/AggregateError.ts | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .changeset/old-forks-think.md diff --git a/.changeset/old-forks-think.md b/.changeset/old-forks-think.md new file mode 100644 index 00000000000..0a064650ff2 --- /dev/null +++ b/.changeset/old-forks-think.md @@ -0,0 +1,5 @@ +--- +'@graphql-tools/utils': patch +--- + +fix(utils): support old TypeScript versions diff --git a/packages/utils/src/AggregateError.ts b/packages/utils/src/AggregateError.ts index 36a877ca2ff..7f0c0012cd2 100644 --- a/packages/utils/src/AggregateError.ts +++ b/packages/utils/src/AggregateError.ts @@ -1,5 +1,15 @@ -/// -let AggregateErrorImpl = globalThis.AggregateError; +// Backwards compability for old versions of TypeScript +interface AggregateError extends Error { + errors: any[]; +} + +interface AggregateErrorConstructor { + new (errors: Iterable, message?: string): AggregateError; + (errors: Iterable, message?: string): AggregateError; + readonly prototype: AggregateError; +} + +let AggregateErrorImpl: AggregateErrorConstructor = globalThis.AggregateError; if (typeof AggregateErrorImpl === 'undefined') { class AggregateErrorClass extends Error implements AggregateError {