Skip to content

Iterator method incorrectly errors when emitting isolatedDeclaration declarations  #8469

@ericrafalovsky

Description

@ericrafalovsky

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

Metadata

Metadata

Assignees

Labels

C-bugCategory - Bug

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions