Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Fix type annotation for imports of erased interfaces #3175

Merged
merged 1 commit into from Sep 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Fable.Transforms/Python/Fable2Python.fs
Expand Up @@ -903,14 +903,18 @@ module Annotation =

if ent.IsInterface then
let name = Helpers.removeNamespace ent.FullName

match entRef.SourcePath with
| Some path when path <> com.CurrentFile ->
// this is just to import the interface
let importPath = Path.getRelativeFileOrDirPath false com.CurrentFile false path

com.GetImportExpr(ctx, importPath, name) |> ignore
| _ -> ()
| _ ->
// If the interface is imported then it's erased and we need to add the actual imports
match ent.Attributes with
| Fable.Transforms.FSharp2Fable.Util.ImportAtt(name, importPath) ->
com.GetImportExpr(ctx, importPath, name) |> ignore
| _ -> ()

makeGenericTypeAnnotation com ctx name genArgs repeatedGenerics, []
else
Expand Down