persona-community-5/.pnpm-store/v3/files/71/66f1c1408d0cc62369990614f2de383d413388f296f1b5aca49a7a81214eb1d2a8c2faf37bd3fc1d68d92b0eeb86cb77b892f9cd6ebb581bcb6aac63688d8b
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

37 lines
1.7 KiB
Plaintext

import type NameManager from "../NameManager";
import type TokenProcessor from "../TokenProcessor";
import Transformer from "./Transformer";
/**
* Transformer supporting the optional chaining and nullish coalescing operators.
*
* Tech plan here:
* https://github.com/alangpierce/sucrase/wiki/Sucrase-Optional-Chaining-and-Nullish-Coalescing-Technical-Plan
*
* The prefix and suffix code snippets are handled by TokenProcessor, and this transformer handles
* the operators themselves.
*/
export default class OptionalChainingNullishTransformer extends Transformer {
readonly tokens: TokenProcessor;
readonly nameManager: NameManager;
constructor(tokens: TokenProcessor, nameManager: NameManager);
process(): boolean;
/**
* Determine if the current token is the last of its chain, so that we know whether it's eligible
* to have a delete op inserted.
*
* We can do this by walking forward until we determine one way or another. Each
* isOptionalChainStart token must be paired with exactly one isOptionalChainEnd token after it in
* a nesting way, so we can track depth and walk to the end of the chain (the point where the
* depth goes negative) and see if any other subscript token is after us in the chain.
*/
isLastSubscriptInChain(): boolean;
/**
* Determine if we are the open-paren in an expression like super.a()?.b.
*
* We can do this by walking backward to find the previous subscript. If that subscript was
* preceded by a super, then we must be the subscript after it, so if this is a call expression,
* we'll need to attach the right context.
*/
justSkippedSuper(): boolean;
}