Skip to content

Generated interface files do not import dependencies #84

@vsvirydau-cl

Description

@vsvirydau-cl

TL;DR

  • If [ExportTs*] targets a class - imports are specified correctly
  • If [ExportTs*] targets an interface - imports are omitted

Problem

I have something like this

# ISomeInterface.cs
[ExportTsInterface]
public interface ISomeInterface {
    IList<IOtherInterface> Others { get; set; }
}

# IOtherInterface.cs
[ExportTsInterface]
public interface IOtherInterface {

}

Generated files:

# i-some-interface.ts
# there's no "import { IOtherInterface } from './i-other-interface.ts';" here
export interface ISomeInterface {
   others: IOtherInterface[];
}

Typescript compiler now gives me an error

ERROR in src/i-some-interface.ts(12,17): error TS2304: Cannot find name 'IOtherInterface'

If I use [ExportTsInterface] on a class instead, *.ts files now correctly have import { IOtherInterface } from ... in them.

Environment

Nuget:
<PackageReference Include="TypeGen" Version="2.4.7" />
Tool:

"dotnet-typegen": {
      "version": "2.4.7",
      "commands": [
        "dotnet-typegen"
      ]
    }

tgconfig:

{
  "assemblies": [
    "src/web/bin/Release/netcoreapp3.0/web.dll",
    "src/web/bin/Release/netcoreapp3.0/core.dll",
    "src/web/bin/Release/netcoreapp3.0/infrastructure.dll"
  ],
  "clearOutputDirectory": true,
  "outputPath": "src/front-end/src/models",
  "createIndexFile": true,
  "enumStringInitializersConverters": [],
  "customTypeMappings": {
    "NodaTime.Instant": "Date"
  }
}

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