Skip to content

play with adding a JSON DTO - #3254

Closed
KATT wants to merge 3 commits into
mainfrom
issues/1694
Closed

KATT wants to merge 3 commits into
mainfrom
issues/1694

Conversation

@KATT

@KATT KATT commented Nov 24, 2022 •

Copy link
Copy Markdown
Member

#1694 (incomplete)

🎯 Changes

  • Not complete. Only POC.

βœ… Checklist

  • I have followed the steps listed in the Contributing guide.
  • If necessary, I have added documentation related to the changes made.
  • I have added or updated the tests related to the changes made.

@vercel

vercel Bot commented Nov 24, 2022 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated
next-prisma-starter βœ… Ready (Inspect) Visit Preview πŸ’¬ Add your feedback Nov 24, 2022 at 10:35PM (UTC)
www βœ… Ready (Inspect) Visit Preview πŸ’¬ Add your feedback Nov 24, 2022 at 10:35PM (UTC)

fn: () => {
return 'hello';
},
arrayWithUndefined: [1, undefined, 2],

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be DTO'd to number[]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A tuple, [1, undefined, 2] as const, on the other hand should be DTO'd to [1, 2]

Comment on lines +30 to +38
type ErrorBranded<T, TMessage extends string> = T & { [errorSymbol]: TMessage };

type ReplaceSet<T> = T extends Set<any>
? ErrorBranded<{}, 'Set is not JSON serializable`'>
: T;

type ReplaceMap<T> = T extends Map<any, any>
? ErrorBranded<{}, 'Map is not JSON serializable'>
: T;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modified these to do what JSON does

@KATT

KATT commented Nov 24, 2022

Copy link
Copy Markdown
Member Author

Bad implementation, good idea. Will update the issue with my findings.

@KATT KATT closed this Nov 24, 2022
@KATT
KATT deleted the issues/1694 branch November 24, 2022 23:27
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Dec 25, 2022

This branch was successfully deployed

3 active deployments
Preview – www β€” 21d5f65f Deployed Nov 24, 2022 by vercel[bot]
Preview – next-prisma-starter β€” 21d5f65f Deployed Nov 24, 2022 by vercel[bot]
Preview – todomvc β€” 21d5f65f Deployed Nov 24, 2022 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant