I'm confused how this was able to give out money before the new code was submitted to production. The author claims that both she and her coworker tested it before the code was submitted and they ended up with the extra $25k. Was this code only executed on the front end? Were there no checks in the backend to prevent employees from just pulling out whatever money they wanted?
Twenty five thousand dollars of funny money
11–20 of 175 posts
Re: Twenty five thousand dollars of funny money
#12I think I like the duck typing in TypeScript more than I dislike it. But I still wish I could say “this function accepts a type called RobotName. It’s a string, but so is RobotUuid, and we don’t want that. So only accept, strictly, objects typed as RobotName.”
type RobotName = string; function foo(r: RobotName) {} ?
Re: Twenty five thousand dollars of funny money
#13I think I like the duck typing in TypeScript more than I dislike it. But I still wish I could say “this function accepts a type called RobotName. It’s a string, but so is RobotUuid, and we don’t want that. So only accept, strictly, objects typed as RobotName.”
type RobotName = string; function foo(r: RobotName) {} ?
type RobotUuid = string;
const bar: RobotUuid = “abc…”;
foo(bar);
This is what duck typing is and specifically my curiosity about being able to de-duck on demand.
Re: Twenty five thousand dollars of funny money
#14I'm confused how this was able to give out money before the new code was submitted to production. The author claims that both she and her coworker tested it before the code was submitted and they ended up with the extra $25k. Was this code only executed on the front end? Were there no checks in the backend to prevent employees from just pulling out whatever money they wanted?
Re: Twenty five thousand dollars of funny money
#15I think I like the duck typing in TypeScript more than I dislike it. But I still wish I could say “this function accepts a type called RobotName. It’s a string, but so is RobotUuid, and we don’t want that. So only accept, strictly, objects typed as RobotName.”
Re: Twenty five thousand dollars of funny money
#16Re: Twenty five thousand dollars of funny money
#17I think I like the duck typing in TypeScript more than I dislike it. But I still wish I could say “this function accepts a type called RobotName. It’s a string, but so is RobotUuid, and we don’t want that. So only accept, strictly, objects typed as RobotName.”
You can kind of do it: interface RobotName { value: string; type: "RobotName"; } Or if you don't want to make an extra wrapper around every object: interface RobotName { _phantomType: "RobotName"; } function makeRobotName(name: string): RobotName { return name as any as RobotName; } function getRobotName(robotName: RobotName): string { return robotName as any as string; } Presumably V8 is smart enough to inline the w…
Re: Twenty five thousand dollars of funny money
#18I think I like the duck typing in TypeScript more than I dislike it. But I still wish I could say “this function accepts a type called RobotName. It’s a string, but so is RobotUuid, and we don’t want that. So only accept, strictly, objects typed as RobotName.”
The closest way to get nominal typing in TypeScript is with type branding. I haven’t actually used this small library, but it illustrates the idea: https://github.com/kourge/ts-brand
Re: Twenty five thousand dollars of funny money
#19I think I like the duck typing in TypeScript more than I dislike it. But I still wish I could say “this function accepts a type called RobotName. It’s a string, but so is RobotUuid, and we don’t want that. So only accept, strictly, objects typed as RobotName.”
or some variation. The marker does not actually need to exist.
Re: Twenty five thousand dollars of funny money
#20I'm confused how this was able to give out money before the new code was submitted to production. The author claims that both she and her coworker tested it before the code was submitted and they ended up with the extra $25k. Was this code only executed on the front end? Were there no checks in the backend to prevent employees from just pulling out whatever money they wanted?
As I understand it the code gave you $25k credit, not $25k actual money.