[GH-ISSUE #8619] Date field types when supportsDates: false #19770

Open
opened 2026-04-15 19:06:40 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @erquhart on GitHub (Mar 15, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8619

When an adapter uses supportsDates: false and customTransformOutput to return non-Date values for date fields, the runtime works correctly. Better-auth already handles this internally by wrapping values in new Date() before calling date methods (see #3611, #3704).

The types don't reflect this, though - date fields always resolve to Date even when the adapter returns something else.

Should we expect the types to account for supportsDates at some point, or should adapters handle this on their end?

Originally created by @erquhart on GitHub (Mar 15, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8619 When an adapter uses `supportsDates: false` and `customTransformOutput` to return non-Date values for date fields, the runtime works correctly. Better-auth already handles this internally by wrapping values in `new Date()` before calling date methods (see #3611, #3704). The types don't reflect this, though - date fields always resolve to `Date` even when the adapter returns something else. Should we expect the types to account for `supportsDates` at some point, or should adapters handle this on their end?
GiteaMirror added the database label 2026-04-15 19:06:40 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 15, 2026):

This is actually tracked in #8618 — the type system currently hardcodes date fields to Date via InferDBValueType with no awareness of adapter configuration.

As of now, there are no confirmed plans or timelines to make types reflect supportsDates. The PRs you mentioned (#3611, #3704) fixed runtime crashes by adding defensive new Date() wrapping, but didn't address the type gap.

A few solutions have been discussed in #8618:

  1. Make InferDBValueType generic over adapter config
  2. Add a type-level hook similar to customTransformOutput
  3. Add a generic type parameter to the adapter factory for field type mapping

For now, adapters need to handle this on their end (either via type assertions or by actually returning Date objects when possible).

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:4063715605 --> @dosubot[bot] commented on GitHub (Mar 15, 2026): <!-- Answer --> This is actually tracked in [#8618](https://github.com/better-auth/better-auth/issues/8618) — the type system currently hardcodes date fields to `Date` via [`InferDBValueType`](https://github.com/better-auth/better-auth/blob/8f47015af223e5db9ff406f6ca8247f6b8dcd9fe/packages/core/src/db/type.ts#L16-L32) with no awareness of adapter configuration. As of now, **there are no confirmed plans or timelines** to make types reflect `supportsDates`. The PRs you mentioned (#3611, #3704) fixed runtime crashes by adding defensive `new Date()` wrapping, but didn't address the type gap. A few solutions have been discussed in #8618: 1. Make `InferDBValueType` generic over adapter config 2. Add a type-level hook similar to `customTransformOutput` 3. Add a generic type parameter to the adapter factory for field type mapping For now, adapters need to handle this on their end (either via type assertions or by actually returning `Date` objects when possible). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/1561be30-ee70-40e1-beab-6e90caed96fa?feedback_type=great_response&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/1561be30-ee70-40e1-beab-6e90caed96fa?feedback_type=irrelevant_answer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/1561be30-ee70-40e1-beab-6e90caed96fa?feedback_type=incorrect_sources&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/1561be30-ee70-40e1-beab-6e90caed96fa?feedback_type=too_verbose&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/1561be30-ee70-40e1-beab-6e90caed96fa?feedback_type=hallucination&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/1561be30-ee70-40e1-beab-6e90caed96fa?feedback_type=bug_report&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report) | [Other](https://app.dosu.dev/response-feedback/1561be30-ee70-40e1-beab-6e90caed96fa?feedback_type=other&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20actually%20tracked%20in%20%5B%238618%5D%28https%3A//github.com/better-auth/better-auth/issues/8618%29%20%E2%80%94%20the%20type%20system%20currently%20hardcodes%20date%20fields%20to%20%60Date%60%20via%20%5B%60InferDBValueType%60%5D%28https%3A//github.com/better-auth/better-auth/blob/8f47015af223e5db9ff406f6ca8247f6b8dcd9fe/packages/core/src/db/type.ts%23L16-L32%29%20with%20no%20awareness%20of%20adapter%20configuration.%0A%0AAs%20of%20now%2C%20%2A%2Athere%20are%20no%20confirmed%20plans%20or%20timelines%2A%2A%20to%20make%20types%20reflect%20%60supportsDates%60.%20The%20PRs%20you%20mentioned%20%28%233611%2C%20%233704%29%20fixed%20runtime%20crashes%20by%20adding%20defensive%20%60new%20Date%28%29%60%20wrapping%2C%20but%20didn%27t%20address%20the%20type%20gap.%0A%0AA%20few%20solutions%20have%20been%20discussed%20in%20%238618%3A%0A1.%20Make%20%60InferDBValueType%60%20generic%20over%20adapter%20config%0A2.%20Add%20a%20type-level%20hook%20similar%20to%20%60customTransformOutput%60%0A3.%20Add%20a%20generic%20type%20parameter%20to%20the%20adapter%20factory%20for%20field%20type%20mapping%0A%0AFor%20now%2C%20adapters%20need%20to%20handle%20this%20on%20their%20end%20%28either%20via%20type%20assertions%20or%20by%20actually%20returning%20%60Date%60%20objects%20when%20possible%29.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/8619)
Author
Owner

@erquhart commented on GitHub (Mar 15, 2026):

@dosubot this replaces #8618, fyi.

<!-- gh-comment-id:4063820409 --> @erquhart commented on GitHub (Mar 15, 2026): @dosubot this replaces #8618, fyi.
Author
Owner

@dosubot[bot] commented on GitHub (Mar 15, 2026):

Got it, thanks for the heads up! I'll reference this issue (#8619) going forward for the supportsDates type inference discussion.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:4063820865 --> @dosubot[bot] commented on GitHub (Mar 15, 2026): <!-- Answer --> Got it, thanks for the heads up! I'll reference this issue (#8619) going forward for the `supportsDates` type inference discussion. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/6b324a47-6771-4ca8-8ddc-6fc4cfd9d982?feedback_type=great_response&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/6b324a47-6771-4ca8-8ddc-6fc4cfd9d982?feedback_type=irrelevant_answer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/6b324a47-6771-4ca8-8ddc-6fc4cfd9d982?feedback_type=incorrect_sources&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/6b324a47-6771-4ca8-8ddc-6fc4cfd9d982?feedback_type=too_verbose&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/6b324a47-6771-4ca8-8ddc-6fc4cfd9d982?feedback_type=hallucination&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/6b324a47-6771-4ca8-8ddc-6fc4cfd9d982?feedback_type=bug_report&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report) | [Other](https://app.dosu.dev/response-feedback/6b324a47-6771-4ca8-8ddc-6fc4cfd9d982?feedback_type=other&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Got%20it%2C%20thanks%20for%20the%20heads%20up%21%20I%27ll%20reference%20this%20issue%20%28%238619%29%20going%20forward%20for%20the%20%60supportsDates%60%20type%20inference%20discussion.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/8619)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#19770