Skip to content

Instantly share code, notes, and snippets.

@matmar10
Created November 15, 2022 05:00
Show Gist options
  • Save matmar10/a5e56049262b71809078f3a8227ba54b to your computer and use it in GitHub Desktop.
Save matmar10/a5e56049262b71809078f3a8227ba54b to your computer and use it in GitHub Desktop.
Demonstrate improper use of switch with object reference
import { Prisma } from '@prisma/client';
function testPrismaDecimal(decimalInstance: Prisma.Decimal) {
console.log('Testing: ', decimalInstance);
switch (decimalInstance) {
case new Prisma.Decimal(0):
console.log('It is: 0');
break;
case new Prisma.Decimal(1):
console.log('It is: 1');
default:
console.log('It is none of those.');
}
}
const tests = [
new Prisma.Decimal(0),
new Prisma.Decimal(1),
new Prisma.Decimal(2),
];
tests.forEach((item) => testPrismaDecimal(item));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment