Fable icon indicating copy to clipboard operation
Fable copied to clipboard

Typescript imports have wrong file extension

Open dburriss opened this issue 1 year ago • 1 comments

Description

When running fable the generated TS files link to JS files that do not exist.

Repro code

https://github.com/dburriss/haya-net/tree/typescript-support/src/Haya.Deno

Note: The deno project is referencing files in another project. Was hoping there was a better way to do this but could not think of anything.

Expected and actual results

When running:

dotnet fable --outDir ./ --lang ts

The generated .ts files contain imports like the following:

import { toString, Record, Union } from "../fable_modules/fable-library-ts.4.24.0/Types.js";
import { bool_type, record_type, string_type, union_type, TypeInfo } from "../fable_modules/fable-library-ts.4.24.0/Reflection.js";
import { IComparable, IEquatable } from "../fable_modules/fable-library-ts.4.24.0/Util.js";
import { StringBuilder__AppendLine, StringBuilder__AppendLine_Z721C83C5, StringBuilder__Append_Z721C83C5, StringBuilder_$ctor_Z721C83C5, StringBuilder_$ctor } from "../fable_modules/fable-library-ts.4.24.0/System.Text.js";
import { FSharpList, fold } from "../fable_modules/fable-library-ts.4.24.0/List.js";

The file ../fable_modules/fable-library-ts.4.24.0/Types.js does not exist though, instead ../fable_modules/fable-library-ts.4.24.0/Types.ts exists (which is what I expect). So the imports are generated expecting .js, when they should be expecting .ts.

Related information

  • Fable version: 4.24.0 (was happening on 4.22.0 too)
  • Operating system: OSX

dburriss avatar Dec 10 '24 06:12 dburriss

Similar to https://github.com/fable-compiler/Fable/issues/3686#issuecomment-1878857962

To allow people consuming Fable => TS with runtimes like Deno we will need to add a new compiler flag.

MangelMaxime avatar Dec 13 '24 08:12 MangelMaxime

I would be interested in this. I’m doing a project which uses Supabase at the moment and their Edge Functions use Deno so it would be nice to have the option to use F# with those without too much fiddling around.

retendo avatar Aug 08 '25 22:08 retendo