Fable icon indicating copy to clipboard operation
Fable copied to clipboard

[TypeScript] Mangled interfaces not created correctly

Open leononame opened this issue 1 year ago • 0 comments

Description

When compiling to TypeScript, interfaces will get compiled as well instead of erased. However, when the Mangle attribute is set, the interfaces will not get mangled, but the implementation will.

Repro code

Repl, or alternatively this F# code:

// Write code or load a sample from sidebar
open Fable.Core

[<Mangle>]
type IPrint = 
    abstract Print: unit -> string

type Print() = 
    interface IPrint with
        member this.Print() = "hello, world"

Expected and actual results

Expected something like this:

import { class_type, TypeInfo } from "fable-library-js/Reflection.js";

export interface IPrint {
    "Test.IPrint.Print"(): string
}

export class Print implements IPrint {
    constructor() {
    }
    "Test.IPrint.Print"(): string {
        return "hello, world";
    }
}

export function Print_$reflection(): TypeInfo {
    return class_type("Test.Print", undefined, Print);
}

export function Print_$ctor(): Print {
    return new Print();
}

But instead, I get this:

import { class_type, TypeInfo } from "fable-library-js/Reflection.js";

export interface IPrint {
    Print(): string
}

export class Print implements IPrint {
    constructor() {
    }
    "Test.IPrint.Print"(): string {
        return "hello, world";
    }
}

export function Print_$reflection(): TypeInfo {
    return class_type("Test.Print", undefined, Print);
}

export function Print_$ctor(): Print {
    return new Print();
}

Related information

  • Fable version: 4.19.3
  • Operating system Linux

leononame avatar Jul 09 '24 16:07 leononame