gleam icon indicating copy to clipboard operation
gleam copied to clipboard

Type constructor `CustomType` breaks js codegen

Open lucasavila00 opened this issue 1 year ago • 1 comments

image

lucasavila00 avatar Aug 10 '22 01:08 lucasavila00

Oops haha! That's quite a funny edge case. We'll have to fix that one.

lpil avatar Aug 10 '22 07:08 lpil

One solution might be to import constructors under a different name if there is a clash. Or perhaps we always import under a different name to make the code simpler.

What might we rename them to?

lpil avatar Aug 16 '22 18:08 lpil

Perhaps they should be imported with the Gleam prefix, for clarity. Although I think it would still require checking for a GleamCustomType export, and changing the alias if that creates a collision.

lucasavila00 avatar Aug 16 '22 18:08 lucasavila00

Perhaps we copy modules and use a $ prefix. Then it will never collide

import { CustomType as $CustomType } from "./gleam.js";

export Thingy extends $CustomType {
  ...
}

lpil avatar Aug 16 '22 18:08 lpil

Yeah, that's better.

lucasavila00 avatar Aug 16 '22 19:08 lucasavila00