Skip to content

feat(minifier): negate binary comparison for typeof x < 'u' - #26367

Merged
Dunqing merged 1 commit into
oxc-project:mainfrom
armano2:feat/string-negation-binnary-comp
Sep 9, 2026
Merged

Dunqing merged 1 commit into
oxc-project:mainfrom
armano2:feat/string-negation-binnary-comp

Conversation

@armano2

@armano2 armano2 commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Allow inversion of binary operation when comparing 'u' string with typeof

!(typeof a < "u") => typeof a > "u"
!(typeof a > "u") => typeof a < "u"

this is needed to support negation of short version of typeof x === "undefined" -> typeof a > "u" generated by substitute_typeof_undefined

fixes #25294
related #26460

@armano2
armano2 requested a review from Dunqing as a code owner September 6, 2026 19:19
@codspeed

codspeed Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 19 skipped benchmarks1


Comparing armano2:feat/string-negation-binnary-comp (0af5552) with main (116c8b8)

Open in CodSpeed

Footnotes

  1. 19 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@armano2
armano2 force-pushed the feat/string-negation-binnary-comp branch 2 times, most recently from 8a24fcd to 1819127 Compare September 6, 2026 19:31
@armano2
armano2 marked this pull request as draft September 6, 2026 20:19
@armano2 armano2 changed the title feat(minifier): add negation of binary comparison for string values feat(minifier): negate binary comparison for typeof x < 'u' Sep 6, 2026
@armano2
armano2 force-pushed the feat/string-negation-binnary-comp branch from ee122b6 to 7486888 Compare September 6, 2026 20:46
@armano2
armano2 marked this pull request as ready for review September 6, 2026 20:51
@armano2
armano2 force-pushed the feat/string-negation-binnary-comp branch from 7486888 to 913f316 Compare September 6, 2026 20:54
@camc314 camc314 added the A-minifier Area - Minification, compression and name mangling, oxc_minifier / oxc_mangler label Sep 6, 2026
@armano2
armano2 force-pushed the feat/string-negation-binnary-comp branch from 913f316 to 8a03a28 Compare September 7, 2026 09:48
@armano2
armano2 force-pushed the feat/string-negation-binnary-comp branch from 8a03a28 to 0af5552 Compare September 7, 2026 13:00
@Dunqing

Dunqing commented Sep 8, 2026

Copy link
Copy Markdown
Member

/monitor-oxc run

@oxc-guard

oxc-guard Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

@Dunqing Dunqing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Dunqing
Dunqing merged commit 80a76a0 into oxc-project:main Sep 9, 2026
44 checks passed
@armano2
armano2 deleted the feat/string-negation-binnary-comp branch September 9, 2026 10:05
graphite-app Bot pushed a commit that referenced this pull request Sep 14, 2026
### 🚀 Features

- ca649e0 ecma: Define math constants as known globals and resolve their types (#26585) (Armano)
- 9ef028c codegen: Add `ascii_only` option (#25994) (Samuel Attard)
- 80a76a0 minifier: Negate binary comparison for `typeof x < 'u'` (#26367) (Armano)

### 🐛 Bug Fixes

- 8ca76da parser: Reject `accessor` modifiers on methods (#26617) (camc314)
- 1916f31 parser: Reject `readonly` modifier on constructors (#26612) (camc314)
- 1c42008 parser: Handle escaped let in for loops (#26583) (camc314)
- d21d5cf parser: Recognize annotated empty arrows in conditionals (#26537) (camc314)
- d7713ad parser: Classify Unicode line breaks in block comments (#26536) (camc314)
- 75cd919 transformer: Preserve receivers in private optional chains (#26535) (camc314)
- b32d25d parser: Reject escaped import-phase keywords (#26534) (camc314)
- 47b8311 parser: Recognize contextual binding names in type lookaheads (#26532) (camc314)
- d6b6705 parser: Require arrow separator in TypeScript function types (#26529) (camc314)
- e98beef parser: Disambiguate await using in for initializers (#26527) (camc314)
- 92afee6 parser: Allow parenthesized JSX comma expressions with preserve_parens=false (#26524) (camc314)
- 31508b1 parser: Reject return types on constructor overloads (#26523) (camc314)
- a091fc4 parser: Validate await context for await using declarations (#26495) (camc314)
- 5501e86 parser: Disallow in expressions in using for-loop initializers (#26490) (camc314)
- c8e5fa7 parser: Allow escaped type names in import and export specifiers (#26487) (camc314)
- 2dcee2f parser: Reject async modifiers on class fields (#26486) (camc314)
- 973d58e parser: Require comma after TypeScript this parameter (#26480) (camc314)
- 32d00c5 codegen: Preserve instantiation expression precedence (#26424) (camc314)
- cfa47ab parser: Allow `in` expressions in class static blocks (#26423) (camc314)
- 5986187 packages/codegen: Preserve private-in right operand precedence (#26420) (camc314)
- f8e6c6c packages/codegen: Preserve in restriction through yield arguments (#26421) (camc314)
- d61e3bf parser: Validate TS named tuple rest elements (#26419) (camc314)
- ae6c386 codegen: Preserve in restriction through yield arguments (#26413) (camc314)
- 42ac916 codegen: Preserve private-in right operand precedence (#26411) (camc314)
- 10521b2 parser: Allow escaped type default import bindings (#26409) (camc314)
- 72cb5e3 parser: Reject rest parameters in getters (#26400) (camc314)
- 6e15ad5 packages/codegen: Print matching quoted import names as identifiers (#26404) (camc314)
- bbbb4bc packages/codegen: Preserve private-in left operand precedence (#26403) (camc314)
- a111b5b packages/codegen: Print accessibility modifiers before abstract (#26402) (camc314)
- 4e76602 parser: Allow `in` in arrow block bodies within `for` initializers (#26395) (camc314)
- b20fc19 parser: Reject partially parenthesized mixed coalesce expressions (#26394) (camc314)

### ⚡ Performance

- 1f902a6 isolated_declarations: Key scope maps by `Ident` (#26380) (Dunqing)
- a242469 minfiier: Reduce allocs when creating indirect access (#26601) (Armano)
- 5b4787f minifier: Update chain expressions in place (#26544) (Armano)
- 0bc1661 minifier: Try merging before creating new expression statements (#26556) (Armano)
- c78d707 minifier: Process newly created stmt in handle_if_statement (#26541) (Armano)
- 029c84b minfier: Update expressions in place when substituting alternate syntax (#26460) (Armano)
- d198982 codegen: Outline postfix source mapping work (#26450) (camc314)
- 53f006e ecmascript: Format small integer literals with itoa (#26446) (camc314)
- 8bfb8c0 codegen: Avoid duplicate sourcemap name lookups (#26441) (camc314)

### 📚 Documentation

- 38533ac ast: Move type annotation span comment to span field (#26522) (camc314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-minifier Area - Minification, compression and name mangling, oxc_minifier / oxc_mangler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

minifier: negation in expression in boolean context

3 participants