import { Match } from 'effect'
type MyTepe = { _tag: 'A' } | undefined
const ok = Match.type<MyTepe>().pipe(
Match.when({ _tag: 'A' }, () => 'A'),
Match.orElse(() => null),
)(undefined)
// Prints: { ok: null }
console.log({ ok })
// Throws:
// node_modules/effect/src/internal/matcher.ts:390
// (_: any) => _[field] in fields,
// TypeError: Cannot read properties of undefined (reading '_tag')
const boom = Match.type<MyTepe>().pipe(
Match.tags({ A: x => x._tag }),
Match.orElse(() => null),
)(undefined)
console.log({ boom })
import { Match } from 'effect'
type MyTepe = { _tag: 'A' } | undefined
const ok = Match.type<MyTepe>().pipe(
Match.when({ _tag: 'A' }, () => 'A'),
Match.orElse(() => null),
)(undefined)
// Prints: { ok: null }
console.log({ ok })
// Throws:
// node_modules/effect/src/internal/matcher.ts:390
// (_: any) => _[field] in fields,
// TypeError: Cannot read properties of undefined (reading '_tag')
const boom = Match.type<MyTepe>().pipe(
Match.tags({ A: x => x._tag }),
Match.orElse(() => null),
)(undefined)
console.log({ boom })