Skip to content

Conversation

@0xe
Copy link
Contributor

@0xe 0xe commented Sep 29, 2025

Description:

Transforms arrays with empty slots correctly.

function* generator() {yield [, 'hello']}

is transformed to:

// ...
function generator() {
    return _ts_generator(this, function(_state) {
        switch(_state.label){
            case 0:
                return [
                    4,
                    [
                        'hello'
                    ]
                ];
            case 1:
                _state.sent();
                return [
                    2
                ];
        }
    });
}

instead of:

function gen() {
    return _ts_generator(this, function (_state) {
        switch (_state.label) {
            case 0:
                return [
                    4,
                    [
                        ,
                        'hello'
                    ]
                ];
            case 1:
                _state.sent();
                return [
                    2
                ];
        }
    });
}

(playground url with 1.13.20)

BREAKING CHANGE:

Related issue (if exists):

@changeset-bot
Copy link

changeset-bot bot commented Sep 29, 2025

🦋 Changeset detected

Latest commit: 8c5c85f

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@0xe 0xe force-pushed the scratch/satish/sparse-array-generators branch 3 times, most recently from f07bf61 to 786fa08 Compare September 29, 2025 13:34
@codspeed-hq
Copy link

codspeed-hq bot commented Sep 29, 2025

CodSpeed Performance Report

Merging #11131 will not alter performance

Comparing 0xe:scratch/satish/sparse-array-generators (8c5c85f) with main (1c9ab27)

Summary

✅ 140 untouched

@0xe 0xe force-pushed the scratch/satish/sparse-array-generators branch 2 times, most recently from 3b384a8 to 83a9a21 Compare September 30, 2025 11:52
@0xe 0xe marked this pull request as ready for review September 30, 2025 12:17
@0xe 0xe requested a review from a team as a code owner September 30, 2025 12:17
@0xe 0xe force-pushed the scratch/satish/sparse-array-generators branch from 83a9a21 to e5dc686 Compare October 1, 2025 04:06
@kdy1 kdy1 added this to the Planned milestone Oct 1, 2025
Added support for handling sparse arrays in generator transforms.
@kdy1 kdy1 requested a review from a team as a code owner October 1, 2025 07:32
@kdy1 kdy1 merged commit 9cd4334 into swc-project:main Oct 1, 2025
18 of 20 checks passed
@kdy1 kdy1 modified the milestones: Planned, v1.13.21 Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants