0

I am writing a "modern" web-based MUD with NodeJS and I have implemented on-line editing used the Monaco editor. I have just discovered a very annoying problem with my approach to defining MUD modules, though. The imported .d.ts files are not providing intellisense because the class definitions from the global scope are being overritten:

Workroom.js (simplified):

MUD.include('Base').defineSingleton(I.Base.Room, function (Room) {
    return class Workroom extends Room {
        create() {
            this
                .setShort("Kriton's Workroom")
                .setLong("This is going to take some time to finish")
                .addExit('out', '/world/sarta/square');
        }
    }
});

Room.d.ts (simplified):

declare class Room extends Container {
    /**
     * Add an exit to the room.
     * @param dir The direction in which to go.
     * @param dest The relative path to the next room.
     * @returns {Room}
     */
    addExit(dir: string, dest: string): Room;
    addExit(dir: string, dest: string, hidden: boolean): Room;
    addExit(dir: string, dest: function): Room;
}

The MUD uses this proprietary loader to try and limit access to Node's global scope and provides it's own mechanism for resolving dependencies. But yeah. The module in this example inherits Room but the passed reference shares the name of the "Room" defined in the Room.d.ts file. Is there a means by which I can mark-up the anonymous function so the editor knows that "Room" is a "Room" from my .d.ts file?

Intellisense Scope Fail

I just need to be able to tell Monaco that the Room parameter is a Room type... can it be done with @jsdoc? (I have tried

4

1 回答 1

0

您是否尝试过如https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-configure-javascript-defaults中所示声明您的签名 ?

只需确保启用诊断:noSemanticValidation: false,

祝你好运

于 2018-06-21T22:06:46.917 回答