Git Product home page Git Product logo

Comments (3)

max-mapper avatar max-mapper commented on August 30, 2024

hmm I actually have no idea sorry, but feel free to leave this issue open
in case someone else does

On Thursday, July 23, 2015, Linda_pp [email protected] wrote:

Hi.

I'm using menubar in TypeScript and found an issue.

When I import menubar as below,

// Definition in lib.d.tsdeclare module "menubar" {
function create(opts: Object): any;
export = create;
}
// ...
// main.tsimport * as menu from 'menubar';

I got an error

browser/main.ts(3,23): error TS2497: Module '"menubar"' resolves to a non-module entity and cannot be imported using this construct.

It seems that menubar is already defined in TypeScript standard lib.d.ts
https://github.com/Microsoft/TypeScript/blob/a24aa6f57d281bafd3535f0f4c3f492364a8b4d6/bin/lib.d.ts#L16369.
It is defined as global variable and leads to above error.

Is there any way to resolve this problem?
Now I avoid this issue in dirty way but it disables type check for whole
menubar module

// Now using JS style require...var menu = require('menubar');


Reply to this email directly or view it on GitHub
#37.

Sent from my phone

from menubar.

rhysd avatar rhysd commented on August 30, 2024

@maxogden

Thanks. I'll do that.

I write the current workaround for me.

I defined the menubar object as below.

declare class MenuBar implements NodeJS.EventEmitter {
    on(event: string, listener: Function): MenuBar;
    once(event: string, listener: Function): MenuBar;
    removeListener(event: string, listener: Function): MenuBar;
    removeAllListeners(event?: string): MenuBar;
    setMaxListeners(n: number): void;
    listeners(event: string): Function[];
    emit(event: string, ...args: any[]): boolean;

    addListener(event: string, listener: Function): MenuBar;
    tray: GitHubElectron.Tray;
    app: GitHubElectron.App;
    window: GitHubElectron.BrowserWindow;
}

And I use it for the returned value from create() as below.

var mainMenu: MenuBar = require('menubar')(menuConfig);

This is better than the workaround I showed previously because now mainMenu has a type.

from menubar.

amaury1093 avatar amaury1093 commented on August 30, 2024

Menubar has since been rewritten into TS. Typings come for free.

from menubar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.