question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide typescript umd global types.

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

Just like the module “@types/react”, it declares a global variable React. If I set allowUmdGlobalAccess to true in tsconfig.json, I can use it directly. “material-ui” should declare the MaterialUI, because in js file it is actually defined.

Examples 🌈

compile this without any import statement.

ReactDOM.render(<MaterialUI.Button>aaa</MaterialUI.Button>,document.getElementById("xxx"));

Motivation 🔦

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
heroboycommented, Apr 5, 2020

hello @oliviertassinari, I think this will not impact non-UMD users. Because if a ts file is a module that use import or export, the umd global is not visible. Unless you set the https://www.typescriptlang.org/en/tsconfig#allowUmdGlobalAccess to true.


And why do you think there are +99% users that use non-UMD? I am not a professional front-end programmer. I have some reasons that use the UMD version.

  1. Fast compile, I don’t need to bundle the very large material-ui and its dependencies to target file.
  2. Easy to setup, because I don’t need to bundle the modules in ‘node_module’
0reactions
heroboycommented, Apr 5, 2020

I think for jquery, it just declare the global variable $ and jQuery in misc.d.ts.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Global: Plugin - TypeScript
UMD. A UMD module is one that can either be used as module (through an import), or as a global (when run in...
Read more >
How to override a TypeScript UMD global type definition?
Consider adding an import instead. It tells me that 'THREE' refers to a UMD global, but the current file is a module. Consider...
Read more >
Consider allowing access to UMD globals from modules #10178
What is a scenario in which your only option is to use the global version of a module, but TypeScript doesn't allow you...
Read more >
Library Structures - TypeScript
Today, most popular globally-accessible libraries are actually written as UMD libraries (see below). UMD library documentation is hard to distinguish from ...
Read more >
Types and type declarations | Manual - Deno
When TypeScript is type checking a file, it only cares about the types for the file ... declarations (UMD declarations) and not ambient/global...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found