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

nested class should have an export strategy #83

Open
MasseGuillaume opened this issue May 31, 2018 · 0 comments
Open

nested class should have an export strategy #83

MasseGuillaume opened this issue May 31, 2018 · 0 comments

Comments

@MasseGuillaume
Copy link

MasseGuillaume commented May 31, 2018

input:

declare module 'vscode' {
  export class Position {
    readonly line: number;
    readonly character: number;
    constructor(line: number, character: number);
  }
}

https://github.com/Microsoft/vscode/blob/e74a6601c3714f98fc63102e8304b00c983b6167/src/vs/vscode.d.ts#L243-L267

output:

@js.native
@JSGlobal("vscode.Position")
class Position protected () extends js.Object {
  def this(line: Double, character: Double) = this()
  def line: Double = js.native
  def character: Double = js.native
}

This is wrong for the vscode project since they use modules to export their code. This is how you would do it with the common js syntax:

const vscode = require("vscode");
const pos = new vscode.Position(0, 0)

expected:

@js.native
@JSImport("vscode", "Position")
class Position protected () extends js.Object {
  def this(line: Double, character: Double) = this()
  def line: Double = js.native
  def character: Double = js.native
}

since from the definition we don't know if the class is exported or available on the global scope, it would make sense to pass a flag: export = global | module to specify the export strategy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant