(
program: ts.Program,
diagnostics: ts.Diagnostic[],
customTransformers: ts.CustomTransformers,
onSourceFile: (sourceFile: ts.SourceFile) => void
)
| 6 | import { getConfigDirectory, resolvePlugin } from "./utils"; |
| 7 | |
| 8 | export function getTransformers( |
| 9 | program: ts.Program, |
| 10 | diagnostics: ts.Diagnostic[], |
| 11 | customTransformers: ts.CustomTransformers, |
| 12 | onSourceFile: (sourceFile: ts.SourceFile) => void |
| 13 | ): ts.CustomTransformers { |
| 14 | const luaTransformer: ts.TransformerFactory<ts.SourceFile> = () => sourceFile => { |
| 15 | onSourceFile(sourceFile); |
| 16 | return ts.createSourceFile(sourceFile.fileName, "", ts.ScriptTarget.ESNext); |
| 17 | }; |
| 18 | |
| 19 | const transformersFromOptions = loadTransformersFromOptions(program, diagnostics); |
| 20 | |
| 21 | const afterDeclarations = [ |
| 22 | ...(transformersFromOptions.afterDeclarations ?? []), |
| 23 | ...(customTransformers.afterDeclarations ?? []), |
| 24 | ]; |
| 25 | |
| 26 | const options = program.getCompilerOptions() as CompilerOptions; |
| 27 | if (options.noImplicitSelf) { |
| 28 | afterDeclarations.unshift(noImplicitSelfTransformer); |
| 29 | } |
| 30 | |
| 31 | return { |
| 32 | afterDeclarations, |
| 33 | before: [ |
| 34 | ...(customTransformers.before ?? []), |
| 35 | ...(transformersFromOptions.before ?? []), |
| 36 | |
| 37 | ...(transformersFromOptions.after ?? []), |
| 38 | ...(customTransformers.after ?? []), |
| 39 | stripParenthesisExpressionsTransformer, |
| 40 | luaTransformer, |
| 41 | ], |
| 42 | }; |
| 43 | } |
| 44 | |
| 45 | export const noImplicitSelfTransformer: ts.TransformerFactory<ts.SourceFile | ts.Bundle> = () => node => { |
| 46 | const transformSourceFile: ts.Transformer<ts.SourceFile> = node => { |
no test coverage detected