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

Iterator method incorrectly errors when emitting isolatedDeclaration declarations #8469

Closed
ericrafalovsky opened this issue Jan 14, 2025 · 0 comments · Fixed by #8475
Closed
Assignees
Labels
C-bug Category - Bug

Comments

@ericrafalovsky
Copy link

The below code appears to incorrectly error when emitting .d.ts with oxc, but works as expected with TypeScript:

export class NumberRange implements Iterable<number> {
    private start: number;
    private end: number;

    constructor(start: number, end: number) {
        this.start = start;
        this.end = end;
    }

    [Symbol.iterator](): Iterator<number> {
        let current = this.start;
        const end = this.end;

        return {
            next(): IteratorResult<number> {
                if (current <= end) {
                    return { value: current++, done: false };
                } else {
                    return { value: undefined, done: true };
                }
            },
        };
    }
}

message: 'TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations.',

See also, similar swc bug in swc-project/swc#9859

@ericrafalovsky ericrafalovsky added the C-bug Category - Bug label Jan 14, 2025
@ericrafalovsky ericrafalovsky changed the title Iterator method incorrectly fails with error when using Iterator method incorrectly errors when emitting isolatedDeclaration declarations Jan 14, 2025
@Boshen Boshen assigned Boshen and Dunqing and unassigned Boshen Jan 14, 2025
Boshen pushed a commit that referenced this issue Jan 14, 2025
…property key (#8475)

close: #8469

No support to report errors for non-global `Symbol` yet, it is hard for the current architecture.
@Dunqing Dunqing closed this as completed Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category - Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants