Skip to content

Choose a tag to compare

@github-actions github-actions released this 06 Oct 20:14
· 322 commits to main since this release
7977ab1

Minor Changes

  • c770e7b: The compiler will now return diagnostics and unique error codes to be handled by the consumer. For example:

    import type { DiagnosticSeverity, DiagnosticCode } from '@astrojs/compiler/types';
    import { transform } from '@astrojs/compiler';
    
    async function run() {
      const { diagnostics } = await transform(file, opts);
    
      function log(severity: DiagnosticSeverity, message: string) {
        switch (severity) {
          case DiagnosticSeverity.Error:
            return console.error(message);
          case DiagnosticSeverity.Warning:
            return console.warn(message);
          case DiagnosticSeverity.Information:
            return console.info(message);
          case DiagnosticSeverity.Hint:
            return console.info(message);
        }
      }
    
      for (const diagnostic of diagnostics) {
        let message = diagnostic.text;
        if (diagnostic.hint) {
          message += `\n\n[hint] ${diagnostic.hint}`;
        }
    
        // Or customize messages for a known DiagnosticCode
        if (diagnostic.code === DiagnosticCode.ERROR_UNMATCHED_IMPORT) {
          message = `My custom message about an unmatched import!`;
        }
        log(diagnostic.severity, message);
      }
    }

Patch Changes

  • 0b24c24: Implement automatic typing for Astro.props in the TSX output