Closed
Description
Description
I was trying to create a field on an extension type making use of external
and static
(representing static properties on JS objects, for this particular use case):
return Field((f) => f
..external = true
..static = true
// more
);
Expected Behavior
I expected that the rendered code would produce something similar to the following
external static JSEnum Blue = /* value */;
This is similar to expected behaviour described in the example here
Actual Behaviour
The code produced was instead the following
static external JSEnum Blue = /* value */;
This code does not work, as passing this through the DartFormatter
in dart_style
produced the following error (separate example):
line 41, column 8 of .: The modifier 'external' should be before the modifier 'static'.
╷
41 │ static external final MathConstants Random;
│ ^^^^^^^^
╵
line 43, column 8 of .: The modifier 'external' should be before the modifier 'static'.
╷
43 │ static external final MathConstants Length;
│ ^^^^^^^^
Reason
After some digging, I found that this was coming from the following:
tools/pkgs/code_builder/lib/src/emitter.dart
Lines 440 to 448 in 7bf22c9