regexFind: /async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$-]*)/
regexReplace: function $1Remove async modifier from ambient context. Ambient contexts (declare module, declare namespace) can only contain type declarations, not executable code with modifiers like async.
declare module "test" {
- async function helper(): Promise<void>
+ function helper(): Promise<void>
}Explanation: Remove async modifier from function declaration in ambient module
declare namespace MyNamespace {
- async function process(): Promise<string>
+ function process(): Promise<string>
}Explanation: Remove async modifier from function declaration in ambient namespace
npx tsc ./docs/1040/index.ts --noEmit --prettydocs/1040/index.ts:2:3 - error TS1040: 'async' modifier cannot be used in an ambient context.
2 async function helper(): Promise<void>
~~~~~OR (without --pretty flag):
docs/1040/index.ts(2,3): error TS1040: 'async' modifier cannot be used in an ambient context.