Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Mismatch between .bs.js and .re.js when adding [@genType] to a shadowed variable #354

Closed
a7c opened this issue Feb 3, 2020 · 1 comment · Fixed by #356
Closed

Mismatch between .bs.js and .re.js when adding [@genType] to a shadowed variable #354

a7c opened this issue Feb 3, 2020 · 1 comment · Fixed by #356

Comments

@a7c
Copy link

a7c commented Feb 3, 2020

Suppose we have the following Module.re:

[@genType]
let test = (~test) => Js.log(test);

let test = () => test(~test="test");

genType would generate types for the first test in Module.re.js, since the annotation was applied there:

const test: <T1>({| +test: T1 |}) => void = function <T1>(Arg1: $any) {
  const result = ModuleBS.test(Arg1.test);
  return result
};;
exports.test = test

But the implementation in Module.bs.js would be for the second test:

function test(param) {
  console.log("test");
  return /* () */0;
}
@cristianoc
Copy link
Collaborator

@a7c to double check: in this case nothing would be exported right?
There's also the issue that if both are annotated, then 2 values with the same name are exported, which is also an error.

cristianoc added a commit that referenced this issue Feb 5, 2020
cristianoc added a commit that referenced this issue Feb 5, 2020
#356)

* Fix issue where a shadowed declaration would be emitted instead of the shadowing one.

Fixes #354.

* Update Changes.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants