Release Notes for 431

Well, the biggest thing is that you don’t actually get the module’s type namespace; you only get the single type of the value you’re trying to import. This often means you have to use some hacks to get the type you actually want to import, and it’s hard to get a well-defined, manually-specified type from another module.

A good example is with classes. Often times the type you want from a class module is the object type, even those these modules return the class value. So with the typeof(require()) syntax, you have two options, which aren’t particularly great:

  1. Use type ObjectType = typeof(require(...).new()). This works, but it still isn’t very great. It’s also really easy to confuse the class type and object type if this is the only available option for other people using your code to import the object type.
    or
  2. Conflate the “Class type” and “Object type”. This is very hacky, but magnalite showed an example of it in this thread: https://devforum.roblox.com/t/the-future-of-oop-in-light-of-typed-luau/554988/10?u=databrain

It would be much nicer if instead you could do export type MyClass = {...} for the object type, and a statement along the lines of import type MyClass from path.to.MyClass or importtypes(path.to.MyClass) to avoid this altogether.

1 Like