Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Facade gen comments information out generating illegal code #32

Closed
jimmyff opened this issue Nov 8, 2017 · 3 comments
Closed

Facade gen comments information out generating illegal code #32

jimmyff opened this issue Nov 8, 2017 · 3 comments

Comments

@jimmyff
Copy link

jimmyff commented Nov 8, 2017

I’m using dart_js_facade_gen and it’s generating this class that is causing errors. It appears to be commenting out information that would lead to illegal field names, this is causing errors.

Example:

@anonymous
@JS()
abstract class Style implements StyleOptions {
  external StyleOptions get String /*":hover"*/;
  external set String /*":hover"*/ (StyleOptions v);
  external StyleOptions get String /*":focus"*/;
  external set String /*":focus"*/ (StyleOptions v);
  external StyleOptions get String /*"::placeholder"*/;
  external set String /*"::placeholder"*/ (StyleOptions v);
  external StyleOptions get String /*"::selection"*/;
  external set String /*"::selection"*/ (StyleOptions v);
  external StyleOptions get String /*":-webkit-autofill"*/;
  external set String /*":-webkit-autofill"*/ (StyleOptions v);

Ths causes the following error:
error: error: line 610 pos 29: getter 'String' conflicts with previously declared getter external StyleOptions get String /*":focus"*/;

The type source file: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/stripe-v3/index.d.ts#L230

Here is the complete generated file: https://github.com/jimmyff/stripe_js_facade/blob/master/lib/src/stripe_js_facade.dart

@jimmyff
Copy link
Author

jimmyff commented Nov 9, 2017

I thought that it might be to do with the colons and hypons not being valid field names, but I've tested by modifying the source files to:

        interface Style extends StyleOptions {
            'hover'?: StyleOptions;
            'focus'?: StyleOptions;
            'placeholder'?: StyleOptions;
            'selection'?: StyleOptions;
            'webkit-autofill'?: StyleOptions;
        }

yet still the field names are commented out:

@anonymous
@JS()
abstract class Style implements StyleOptions {
  external StyleOptions get String /*"hover"*/;
  external set String /*"hover"*/ (StyleOptions v);
  external StyleOptions get String /*"focus"*/;
  external set String /*"focus"*/ (StyleOptions v);
  external StyleOptions get String /*"placeholder"*/;
  external set String /*"placeholder"*/ (StyleOptions v);
  external StyleOptions get String /*"selection"*/;
  external set String /*"selection"*/ (StyleOptions v);
  external StyleOptions get String /*"webkit-autofill"*/;
  external set String /*"webkit-autofill"*/ (StyleOptions v);

@jimmyff
Copy link
Author

jimmyff commented Nov 9, 2017

As well as the above examples there are loads of other areas of this definition file that also don't generate the enums:

    type brandType = 'Visa' | 'American Express' | 'MasterCard' | 'Discover' | 'JCB' | 'Diners Club' | 'Unknown';
    type checkType = 'pass' | 'fail' | 'unavailable' | 'unchecked';
    type fundingType = 'credit' | 'debit' | 'prepaid' | 'unknown';
    type tokenizationType = 'apple_pay' | 'android_pay';
// ...
        tokenization_method?: tokenizationType;

Results in more commented out code and falls back to supporting Strings:

/*type brandType = 'Visa' |
    'American Express' |
    'MasterCard' |
    'Discover' |
    'JCB' |
    'Diners Club' |
    'Unknown';*/
/*type checkType = 'pass' | 'fail' | 'unavailable' | 'unchecked';*/
/*type fundingType = 'credit' | 'debit' | 'prepaid' | 'unknown';*/
/*type tokenizationType = 'apple_pay' | 'android_pay';*/
// ...
  external set tokenization_method(String /*'apple_pay'|'android_pay'*/ v);

@derekxu16
Copy link
Contributor

Fixed by #43 and #64. Special characters like : are still not supported yet though so the properties will have to be renamed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants