Skip to content

Commit

Permalink
fix(utils): support old TypeScript versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Aug 4, 2021
1 parent bd31967 commit 0483004
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/old-forks-think.md
@@ -0,0 +1,5 @@
---
'@graphql-tools/utils': patch
---

fix(utils): support old TypeScript versions
14 changes: 12 additions & 2 deletions packages/utils/src/AggregateError.ts
@@ -1,5 +1,15 @@
/// <reference lib="es2021.promise" />
let AggregateErrorImpl = globalThis.AggregateError;
// Backwards compability for old versions of TypeScript
interface AggregateError extends Error {
errors: any[];
}

interface AggregateErrorConstructor {
new (errors: Iterable<any>, message?: string): AggregateError;
(errors: Iterable<any>, message?: string): AggregateError;
readonly prototype: AggregateError;
}

let AggregateErrorImpl: AggregateErrorConstructor = globalThis.AggregateError;

if (typeof AggregateErrorImpl === 'undefined') {
class AggregateErrorClass extends Error implements AggregateError {
Expand Down

1 comment on commit 0483004

@vercel
Copy link

@vercel vercel bot commented on 0483004 Aug 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.