ios icon indicating copy to clipboard operation
ios copied to clipboard

feat: add protocol information to native types

Open edusperoni opened this issue 4 months ago • 0 comments

This is a possible breaking change

This adds additional information to native types that expect some kind of protocol.

Before:

@protocol Option                                                                                
-(NSString *) optionId;                                 
-(NSString *) type;                    
@end                                      
typedef NSObject<Option> Option; 

@protocol Info                                                                                 
-(NSArray<NSObject<Option> *> *) getOptions;
-(NSObject<Option> *) getOption;
@end
typedef NSObject<Info> Info;

Generated:

interface Option {                                      
                                                        
        optionId(): string;                             
                                                        
        type(): string;                                 
}                                                       
declare var Option: {                                   
                                                        
        prototype: Option;                              
};

interface Info {

	getOption(): NSObject;          
            
        getOptions(): NSArray<NSObject>;
                                           
}                  
declare var Info: {       
                                            
        prototype: Info;          
};

##After

interface Info {

	getOption(): NSObject & Option;

	getOptions(): NSArray<NSObject & Option>;
}
declare var Info: {

	prototype: Info;
};

interface Option {

	optionId(): string;

	type(): string;
}
declare var Option: {

	prototype: Option;
};

Possible breaking change

Types are a bit more strict, so anyone relying on the old types might get a compilation error after this.

Implements https://github.com/NativeScript/ios/issues/205

edusperoni avatar Apr 10 '24 17:04 edusperoni