Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: ReadonlyDate #963

Open
1 task done
sindresorhus opened this issue Oct 3, 2024 · 2 comments
Open
1 task done

Proposal: ReadonlyDate #963

sindresorhus opened this issue Oct 3, 2024 · 2 comments

Comments

@sindresorhus
Copy link
Owner

sindresorhus commented Oct 3, 2024

Type description + examples

Would be annoying as input, but can be useful as a return value.

Type source

type ReadonlyDate = Omit<Date, `set${string}`>;

Search existing types and issues first

  • I tried my best to look for it

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • The funding will be given to active contributors.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@fregante
Copy link
Collaborator

fregante commented Oct 6, 2024

Would be annoying as input

I think that kills it, because you can't assign this return value to anything that accepts Date, so it's barely "read-only". Having to use date as Date every time isn't great

@voxpelli
Copy link
Collaborator

Would probably be better to do this as a typed readonly wrapper / proxy to Date with a way to get a full date.

const foo: ReadonlyDate = new ReadonlyDate();
const bar: Date = foo.getDate();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants