Skip to content

Browser: Provide a way to use stompjs from TypeScript without modules #24

Open
@Follpvosten

Description

@Follpvosten

See: #24 (comment) for a workaround

My situation is this: I want to avoid stuff like webpack and so on, instead, I have this in my <head>:

<script type="text/javascript" src="js/jquery.js"></script>                                                                                                                                                              
<script type="text/javascript" src="js/stomp.umd.min.js"></script>                                                                                                                                                       
<script type="text/javascript" src="js/common.js"></script>                                                                                                                                                              
<script type="text/javascript" src="js/chat.js"></script>

And module is set to none in my tsconfig.json.

In this specific case, my TypeScript project resides in a completely different folder and has that "js/" directory as the outDir.

For jQuery, this:

npm i --save-dev @types/jquery

is enough to get jQuery type checking, autocompletion etc. in my .ts files, thanks to this declaration:

declare const jQuery: JQueryStatic;
declare const $: JQueryStatic;

Now when I add stompjs to the TS project:

npm i --save-dev @stomp/stompjs

Nothing of sort becomes available; it looks like StompJs 100% hard depends on module loading when it comes to TypeScript.

According to the docs, including stomp.umd.min.js does give you a globally accessible StompJs object, but it does not look like there's a way to use it with type checking from TypeScript.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions