Skip to content

Issue: Incorrect syntax highlighting when using TypeScript destructuring operator #243

@ProRedCat

Description

@ProRedCat

I've encountered an issue where the code highlight colouring falls apart once it encounters destructuring in TypeScript code blocks.

My solution is to just comment out the destructuring to correctly highlight the remaining code. While this is a niche case it would be great for rehype-pretty-code to support this :)

Here is the code blog which is causing issues, attached after is some screenshots of what rehype-pretty-code colours them as

private async handleSaveMyBusStopQuestion(
        question: SaveMyBusStopQuestion,
    ): Promise<Result<SaveMyBusStopAnswer, Error>> {
        // Destructuring isn't highlighting correctly :(
        const [persistentState, stopRes] = await Promise.all([
            question.persistentState,
            this.edge.getStop(question.userStopId, Optional.none()),
        ]);

        if (stopRes.err) return stopRes;

        persistentState.mutate((pState) => {
            pState.userStop = stopRes.val;
        });

        return Ok(new SaveMyBusStopAnswer(stopRes.val));
}

image

Commenting out the destructuring in this
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions