You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
The text was updated successfully, but these errors were encountered:
ncave
added a commit
to ncave/Fable
that referenced
this issue
Oct 15, 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 containimport { IErrorInterface } from "./Source.fs.js";
even though noSource.fs.js
is created, and if aSource.fs.js
was created (e.g. the file contains functions), there wouldn't be anIErrorInterface
in it to import anyways.In
Program.fs
, you can uncomment the types defined aboveErrorUnion
and then comment outErrorUnion
, 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
The text was updated successfully, but these errors were encountered: