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

Support Export Assignment #24

Closed
evaera opened this issue Sep 25, 2018 · 0 comments
Closed

Support Export Assignment #24

evaera opened this issue Sep 25, 2018 · 0 comments
Assignees

Comments

@evaera
Copy link

evaera commented Sep 25, 2018

Support export assignment (export =) and handle importing with import x = require(...). This will make typing Lua modules much more versatile.

Take care to handle export merging, for example:

declare module "something" {
  function something (): void
  namespace something {
    export interface Animal {
      species: string
    }
    export const value = 5 // values are also allowed... which is bad.
  }
  export = something
}

Export assignments that are merged with a namespace can be imported with the import * as syntax:

import * as something from "something";

something()

const x = something.value // Bad, values don't make sense here in the sense of Lua
// We should throw an error when code tries to access a member from a merged namespace 

let y: something.Animal // Good, types are useful
import { Animal } from "something" // This syntax can be used to access the namespace portion only
import something = require("something") // This syntax can be used to access the function only
// This is also the only way you can import it if there is no namespace being merged into the export.
@osyrisrblx osyrisrblx self-assigned this Sep 25, 2018
@osyrisrblx osyrisrblx added this to the Version 1.0 milestone Sep 25, 2018
@osyrisrblx osyrisrblx removed this from the Version 1.0 milestone Nov 3, 2018
osyrisrblx pushed a commit that referenced this issue Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants