diff --git a/lib/types.js b/lib/types.js index ee17b5ef..7a8331e0 100644 --- a/lib/types.js +++ b/lib/types.js @@ -1243,7 +1243,7 @@ function generateProjectionIndexer(projectionFn) { }; } -function generateDefaultIndexer(types) { +function generateDefaultIndexer(types, self) { const dynamicBranches = []; const bucketIndices = {}; @@ -1271,7 +1271,7 @@ function generateDefaultIndexer(types) { } else { let bucket = getTypeBucket(type); if (bucketIndices[bucket] !== undefined) { - throw new Error(`ambiguous unwrapped union: ${j(this)}`); + throw new Error(`ambiguous unwrapped union: ${j(self)}`); } bucketIndices[bucket] = index; } @@ -1314,7 +1314,7 @@ class UnwrappedUnionType extends UnionType { } this._getIndex = _projectionFn ? generateProjectionIndexer(_projectionFn) - : generateDefaultIndexer(this.types); + : generateDefaultIndexer(this.types, this); Object.freeze(this); }