Skip to content

UseDefaultExport breaks interface inheritance #128

@ghost

Description

When using the API, adding the UseDefaultExport option breaks the class inheritance on extracted TypeScript classes.

public interface IId
{
    int Id { get; set; }
}

public interface IIdentifier
{
    string Identifier { get; set; }
}

public class ProductDto : IId, IIdentifier
{
    public int Id { get; set; }
    public string Identifier { get; set; }
}

var gen = new Generator
{
    Options =
    {
        BaseOutputDirectory = "./types",
        UseDefaultExport = true // adding this option
    }
};

internal class MyGenerationSpec : GenerationSpec
{
    public MyGenerationSpec()
    {
        AddClass<ProductDto>();
    }
}

gen.Generate(new List<GenerationSpec>(new[] { new MyGenerationSpec() }));

Expected :

/**
 * This is a TypeGen auto-generated file.
 * Any changes made to this file can be lost when this file is regenerated.
 */

import IId from "./i-id";
import IIdentifier from "./i-identifier";

class ProductDto implements IId, IIdentifier {
    id: number;
    identifier: string;
}
export default ProductDto;

Actual:

/**
 * This is a TypeGen auto-generated file.
 * Any changes made to this file can be lost when this file is regenerated.
 */

import IId from "./i-id";
import IIdentifier from "./i-identifier";

class ProductDto { // => missing implements IId, IIdentifier 
    id: number;
    identifier: string;
}
export default ProductDto;

Done with :

  • net6.0 console app
  • TypeGen 3.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions