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

Interface imported in generated javascript when DU has an interface type constraint #3541

Closed
sasmithjr opened this issue Oct 14, 2023 · 0 comments · Fixed by #3545
Closed

Comments

@sasmithjr
Copy link
Contributor

sasmithjr commented Oct 14, 2023

Description

When an interface is defined in one file and the interface is used as a generic interface type constraint for a discriminated union in another file, the generated JavaScript file containing the DU attempts to import the interface even though no code is generated for the interface.

This bug is not present in 4.1.2; it was introduced in 4.1.3 and it is still present in 4.2.2.

Repro code

https://github.com/sasmithjr/fable-interface-union for a repo that demonstrates the error.

The interface is defined here https://github.com/sasmithjr/fable-interface-union/blob/7eedf8c90b4d7c45319f32a6e3bfc0c2d35d2e38/Source.fs

The DU with the interface type constraint is defined here https://github.com/sasmithjr/fable-interface-union/blob/7eedf8c90b4d7c45319f32a6e3bfc0c2d35d2e38/Program.fs#L16C1-L17C22

The generated Program.fs.js will contain import { IErrorInterface } from "./Source.fs.js"; even though no Source.fs.js is created, and if a Source.fs.js was created (e.g. the file contains functions), there wouldn't be an IErrorInterface in it to import anyways.

In Program.fs, you can uncomment the types defined above ErrorUnion and then comment out ErrorUnion, and you'll be able see that the other types do not generate code which attempts to import the interface.

Expected and actual results

The generated JavaScript does not import the interface.

Related information

  • Operation system: macOS 14.0
  • .NET SDK: 7.0.401 and 8.0.100-rc.2.23502.2
  • Fable compiler: 4.1.3 and 4.2.2
ncave added a commit to ncave/Fable that referenced this issue Oct 15, 2023
@ncave ncave mentioned this issue Oct 15, 2023
ncave added a commit that referenced this issue Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant