Skip to content

implicit conversion import error when DateTime promoted to DateTimeOffset #3908

Description

@joprice

Description

When a DateTime gets implicitly converted to a DateTimeOffset, the import op_Implicit is missing in the js library:

SyntaxError: The requested module 'https://fable.io/repl/js/repl/fable-library-js/DateOffset.js' does not provide an export named 'op_Implicit' (at 0110e4f1-0010-49d1-b621-0c084f71ae75:62:10)

Repro code

open System

let _: DateTimeOffset = DateTime.UtcNow.Date
import { op_Implicit } from "fable-library-js/DateOffset.js";
import { utcNow, date } from "fable-library-js/Date.js";

op_Implicit(date(utcNow()));

Related information

  • Fable version: 4.19.3
  • Operating system: OSX

Activity

  1. MangelMaxime commented on Sep 29, 2024

    @MangelMaxime
    Member

    I think we can just alias to op_Implicit to fromDate:

    // Write code or load a sample from sidebar
    open System
    
    let _: DateTimeOffset = DateTime.UtcNow.Date
    
    let x = DateTimeOffset(DateTime.UtcNow.Date)
    import { fromDate, op_Implicit } from "fable-library-js/DateOffset.js";
    import { utcNow, date } from "fable-library-js/Date.js";
    
    op_Implicit(date(utcNow()));
    
    export const x = fromDate(date(utcNow()));

    We can do it directly in the Replacement module to avoid having a new function in fable-library, I will have a look at it later.

  2. added a commit that references this issue on Mar 18, 2026
    79c0b67
  3. github-actions commented on Mar 18, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    I've submitted a fix for this issue. The root cause is exactly as @MangelMaxime identified: op_Implicit falls through to the catch-all handler in dateTimeOffset replacements, which generates import { op_Implicit } from "…/DateOffset.js" — but that function doesn't exist.

    Fix: Added an explicit "op_Implicit" case in src/Fable.Transforms/Replacements.fs that redirects to the existing fromDate function (the same one used by the .ctor path when a DateTime argument is passed):

    | "op_Implicit" ->
        Helper.LibCall(com, moduleName, "fromDate", t, args, i.SignatureArgTypes, ?loc = r)
        |> Some

    A draft PR has been opened with this change and a test that verifies the round-trip let dto: DateTimeOffset = d → dto.UtcDateTime = d.

    Generated by Repo Assist · ◷

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions