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

Cannot import createCanvas #9

Open
DOEHOONLEE opened this issue Jul 18, 2022 · 1 comment
Open

Cannot import createCanvas #9

DOEHOONLEE opened this issue Jul 18, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@DOEHOONLEE
Copy link

Hi. I'm trying to use Babylon.js within TypeScript project so I installed "node-canvas-webgl" using npm.

However, when I try to use createCanvas, it keeps importing from node Canvas module instead of node-canvas-webgl's ../lib.

Also, this global declaration part keeps giving me errors like Unresolved variable HTMLElement

// polyfill
global.HTMLElement = function () {};
// -> Unresolved variable HTMLElement 
global.window = {
  setTimeout,
  addEventListener() {},
};
global.navigator = {};
global.document = {
  createElement() {
    return createCanvas(300, 150);
  },
  addEventListener() {},
};

I have included the following codes for global declaration.

declare global {
    var HTMLElement:any;
    var window:any;
    var navigator:any;
    var document:any;
}

export {}

Is there some way to use these codes in TypeScript without any issues?

Thank you :)

@DOEHOONLEE
Copy link
Author

declare global {
    HTMLElement:any = function () { };
    window:any = {
        setTimeout,
        addEventListener() {},
    };
    navigator:any = {};
    document:any = {
        addEventListener() {},
    };
}

tried this and it's still not working :(

@akira-cn akira-cn added the enhancement New feature or request label Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants