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

types: separate out deprecated highlight overload #3987

Merged
merged 2 commits into from
Feb 20, 2024

Conversation

mmkal
Copy link
Contributor

@mmkal mmkal commented Feb 15, 2024

Minor thing in the type definitions I noticed. The .js makes it clear that the old API looks like highlight(lang, code, ignoreIllegals), and the new API looks like highlight(code, {lang, ignoreIllegals}).

The types on the other hand imply you could do things like highlight(code, {lang: ...}, true) - but that true would be ignored at runtime.

Changes

So this separates the two forms into function overloads, and adds a /** @deprecated */ tag to the old form so IDEs will hint not to use it.

Checklist

  • markup tests don't apply here because this is just a type definition update
  • Updated the changelog at CHANGES.md

Minor thing in the type definitions I noticed. The .js makes it clear that the old API looks like `highlight(lang, code, ignoreIllegals)`, and the new API looks like `highlight(code, {lang, ignoreIllegals})`.

The types on the other hand imply you could do things like `highlight(code, {lang: ...}, true)` - but that `true` would be ignored at runtime.

So this separates the two forms into function overloads, and adds a `/** @deprecated */` tag to the old form so IDEs will hint not to use it.
Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change -112 B

View Changes
file base pr diff
es/core.min.js 8.17 KB 8.17 KB -1 B
es/highlight.min.js 8.17 KB 8.17 KB -1 B
es/languages/markdown.min.js 960 B 905 B -55 B
highlight.min.js 8.21 KB 8.2 KB -1 B
languages/markdown.min.js 960 B 906 B -54 B

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

3 files changed

Total change +3 B

View Changes
file base pr diff
es/core.min.js 8.17 KB 8.17 KB +1 B
es/highlight.min.js 8.17 KB 8.17 KB +1 B
highlight.min.js 8.21 KB 8.21 KB +1 B

@joshgoebel joshgoebel merged commit 8e61102 into highlightjs:main Feb 20, 2024
15 checks passed
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