@typespec/compiler
Version:
TypeSpec Compiler Preview
31 lines • 850 B
TypeScript
import type { CodeFix, Node } from "../core/types.js";
export interface CodeFixExpect {
toChangeTo(code: string): Promise<void>;
}
/**
* Test a code fix that only needs the ast as input.
* @param code Code to parse. Use ┆ to mark the cursor position.
* @param callback Callback to create the code fix it takes the node at the cursor position.
*
* @example
*
* ```ts
* await expectCodeFixOnAst(
* `
* model Foo {
* a: ┆number;
* }
* `,
* (node) => {
* strictEqual(node.kind, SyntaxKind.Identifier);
* return createChangeIdentifierCodeFix(node, "int32");
* }
* ).toChangeTo(`
* model Foo {
* a: int32;
* }
* `);
* ```
*/
export declare function expectCodeFixOnAst(code: string, callback: (node: Node) => CodeFix): CodeFixExpect;
//# sourceMappingURL=code-fix-testing.d.ts.map