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

[DT] Sample showing one of possible rewrites #3075

Closed

Conversation

peterblazejewicz
Copy link

@joshgoebel
As discussed

Thanks!

Imagine you're a first time user that found the project and followed the 'Usage' link. The usage is for non-module usage:

/// <reference types="highlight.js" />
/// <reference types="vue" />
document.addEventListener("DOMContentLoaded", (event) => {
  document.querySelectorAll<HTMLElement>("pre code").forEach((block) => {
    hljs.highlightBlock(block);
  });
});

const matchType: hljs.MatchType = "end";

Vue.use(hljs.vuePlugin);

Try the same code with your current types, to see the difference.
This one is just sample for global script, ESM should be based on same code base really.

As discussed on DT project

Thanks!
@joshgoebel
Copy link
Member

joshgoebel commented Mar 26, 2021

If I did this I'd still need declare module to make it work for people using modules though, yes? I tried just putting these files in the "magic" locations and that doesn't seem to do anything auto-magically I still get:

Could not find a declaration file for module 'highlight.js/lib/core'. '/Users/jgoebel/work/highlight.js/build/lib/core.js' implicitly has an 'any' type.

If someone is using TS already isn't modules probably much more common?

@peterblazejewicz
Copy link
Author

those are still modules. They are consumed in global script.
Anyway, this was just a sample of where to 'export', 'declare namespace' or potentially split into files,
but you've sorted this out already by moving everything into inline module.
thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants