Created
November 15, 2022 05:00
-
-
Save matmar10/a5e56049262b71809078f3a8227ba54b to your computer and use it in GitHub Desktop.
Demonstrate improper use of switch with object reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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