mirror of
https://github.com/github/codeql-action.git
synced 2025-12-30 03:00:13 +08:00
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com> Co-authored-by: Henry Mercer <henrymercer@github.com>
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { Node } from './Node';
|
|
import { Code } from './Code';
|
|
/**
|
|
* Helps output conditional helper methods.
|
|
*
|
|
* The `ConditionalOutput` concept is split into a usage site and a declaration
|
|
* site, i.e. declaring a `function someHelper() { ... }`, and calling it
|
|
* like `someHelper()`.
|
|
*
|
|
* While generating code, you can make usage says by using `someHelper` as
|
|
* a placeholder, and then output the declaration with `someHelper.ifUsed`
|
|
* to output the declaration conditionally only if `someHelper` has been
|
|
* seen in the tree.
|
|
*
|
|
* ```typescript
|
|
* const someHelper = conditionalOutput(
|
|
* "someHelper",
|
|
* code`function someHelper() { return 1 } `
|
|
* );
|
|
*
|
|
* const code = code`
|
|
* ${someHelper}
|
|
*
|
|
* ${someHelper.ifUsed}
|
|
* `
|
|
* ```
|
|
*/
|
|
export declare class ConditionalOutput extends Node {
|
|
usageSiteName: string;
|
|
declarationSiteCode: Code;
|
|
constructor(usageSiteName: string, declarationSiteCode: Code);
|
|
get childNodes(): unknown[];
|
|
toCodeString(): string;
|
|
get ifUsed(): MaybeOutput;
|
|
}
|
|
export declare class MaybeOutput {
|
|
parent: ConditionalOutput;
|
|
code: Code;
|
|
constructor(parent: ConditionalOutput, code: Code);
|
|
}
|