Originally posted: Azure/azure-sdk-for-net#54788
Per best practice of writing an emitter or typespec library, we should have signatures like this:
getStuff(): [Stuff, readonly Diagnostic[]]
Therefore here, we are making the following changes:
- in
emitter.ts file, wrap everything inside the if (!program.compilerOptions.noEmit && !program.hasError()) into a new function, which returns [void, readonly Diagnostic[]].
- refactor the
createCodeModel method to make it return [CodeModel, readonly Diagnostic[]] instead. Inside the createCodeModel method, see if there are code snippets calling the reportDiagnostic method, we need to change them to append the diagnostic into the array and return it.
Originally posted: Azure/azure-sdk-for-net#54788
Per best practice of writing an emitter or typespec library, we should have signatures like this:
Therefore here, we are making the following changes:
emitter.tsfile, wrap everything inside theif (!program.compilerOptions.noEmit && !program.hasError())into a new function, which returns[void, readonly Diagnostic[]].createCodeModelmethod to make it return[CodeModel, readonly Diagnostic[]]instead. Inside thecreateCodeModelmethod, see if there are code snippets calling thereportDiagnosticmethod, we need to change them to append the diagnostic into the array and return it.