deno_core icon indicating copy to clipboard operation
deno_core copied to clipboard

fix: improve `extension!` macro

Open magurotuna opened this issue 1 year ago • 2 comments

This commit makes the following refinements for extension! macro:

  • Improve the doc comments to cover all the fields available now (i.e. external_references and customizer)
  • Fix the wrong field name in the doc (config -> options)
  • Fix the compile error regarding a wrong expansion of repetitive external_references elements
  • Let it correctly handle the cases where options are provided but state_fn is not. For example, the previous implementation emits a compile error for the code below, which is fixed in this patch:
deno_core::extension!(
  my_ext,
  options = { value: String },
);
error: expected expression, found `;`
  --> src/bin/deno_core_extension.rs:15:1
   |
15 | / deno_core::extension!(
16 | |     my_ext,
17 | |     options = { value: String },
18 | | );
   | |_^ expected expression
   |
   = note: this error originates in the macro `$crate::extension` which comes from the expansion of the macro `deno_core::extension` (in Nightly builds, run with -Z macro-backtrace for more info)

magurotuna avatar Aug 23 '24 05:08 magurotuna

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 23 '24 05:08 CLAassistant

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 81.90%. Comparing base (0c7f83e) to head (4e10dc5). Report is 111 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #881      +/-   ##
==========================================
+ Coverage   81.43%   81.90%   +0.46%     
==========================================
  Files          97       98       +1     
  Lines       23877    24930    +1053     
==========================================
+ Hits        19445    20418     +973     
- Misses       4432     4512      +80     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Aug 24 '24 00:08 codecov-commenter

not sure if this is still revevant. closing it for now

magurotuna avatar Apr 01 '25 13:04 magurotuna