highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.3k stars 3.52k forks source link

types: separate out deprecated `highlight` overload #3987

Closed mmkal closed 4 months ago

mmkal commented 4 months ago

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

github-actions[bot] commented 4 months ago

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 |
github-actions[bot] commented 4 months ago

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 |