Skip to content

Commit ae0b8ac

Browse files
authored
Fix ambiguous union error message (#487)
Was broken via #469. Without this fix, the error message is `undefined`.
1 parent 5db1165 commit ae0b8ac

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/types.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ function generateProjectionIndexer(projectionFn) {
12431243
};
12441244
}
12451245

1246-
function generateDefaultIndexer(types) {
1246+
function generateDefaultIndexer(types, self) {
12471247
const dynamicBranches = [];
12481248
const bucketIndices = {};
12491249

@@ -1271,7 +1271,7 @@ function generateDefaultIndexer(types) {
12711271
} else {
12721272
let bucket = getTypeBucket(type);
12731273
if (bucketIndices[bucket] !== undefined) {
1274-
throw new Error(`ambiguous unwrapped union: ${j(this)}`);
1274+
throw new Error(`ambiguous unwrapped union: ${j(self)}`);
12751275
}
12761276
bucketIndices[bucket] = index;
12771277
}
@@ -1314,7 +1314,7 @@ class UnwrappedUnionType extends UnionType {
13141314
}
13151315
this._getIndex = _projectionFn
13161316
? generateProjectionIndexer(_projectionFn)
1317-
: generateDefaultIndexer(this.types);
1317+
: generateDefaultIndexer(this.types, this);
13181318

13191319
Object.freeze(this);
13201320
}

0 commit comments

Comments
 (0)