question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generated interface files do not import dependencies

See original GitHub issue

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"
  }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jburzynskicommented, Nov 24, 2019

Hey, this is just an update that although I haven’t released the fix, I do keep this issue in mind and I’ll fix it whenever I have a moment for it.

0reactions
vsvirydau-clcommented, Dec 16, 2019

Looks like it works fine. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't use interfaces from another file when they import any ...
typescript - Can't use interfaces from another file when they import any dependencies - Stack Overflow.
Read more >
Update on implementation-only imports - Compiler
A generated module interface (.swiftinterface file) will not make any mention of SecretKit, and should not reference anything from SecretKit ...
Read more >
Can´t get my interface file working
I have generated an interface file and have the project structure set up accodring to your guidance in Intellij. But it can´t find...
Read more >
IntelliJ not able to resolve classes of external Libraries for ...
I imported a maven project and IntelliJ was able to load all the dependencies. Project is building fine. Issue is in all my...
Read more >
3.7. Separate compilation
The interface file for A contains information needed by the compiler when it compiles any module B that imports A, whether directly or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found