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 {