Skip to content
This repository has been archived by the owner on Jan 11, 2018. It is now read-only.

chore: bump to latest typescript 2.2 #274

Closed
Hotell opened this issue Mar 8, 2017 · 1 comment
Closed

chore: bump to latest typescript 2.2 #274

Hotell opened this issue Mar 8, 2017 · 1 comment

Comments

@Hotell
Copy link
Collaborator

Hotell commented Mar 8, 2017

Current behavior

We are using RC which doesn't work as it should.

There are important errors with stable branch ( when used for mixins )

se related issue microsoft/TypeScript#338 (comment)

So as it turns out, at this moment we have 2 options how to reuse property definitions etc:

type ButtonProps = {...} & ColoredProps & DisabledProps;

@Colored()
@Disabled()
class Button extends Component<ButtonProps>{
   @prop ghost: boolean;
   @prop block: boolean;
   
   // redeclare props :(
   color: ColorType;
   disabled: boolean;
}
  • via inheritance -> instead of class extends Component<any> --> class extends Disabled
class ColoredAndDisabled extends Component<Props>{
   static get props(){
       return {
          disabled: prop.boolean(),
          color: prop.string(),
       }
   }

   color: ColorType;
   disabled: boolean;
   
}

class Button extends ColoredAndDisabled {
   @prop ghost: boolean;
   @prop block: boolean;
   
      // no redeclare needed :) ! but this is not composable - because how inheritance works
}

this is very unfortunate indeed ( limitation of Typescript - it works ofc within Vanilla JS.

There is one last hope - to try define mixins via our custom @prop decorator TODO @Hotell

Expected behavior

bump to stable latest TSC and resolve issues

@Hotell
Copy link
Collaborator Author

Hotell commented Mar 8, 2017

yay works!

export function Colored<BC extends Constructable<{}>>( Base: BC ) {
  class ColoredCmp extends Base {
    @prop({type: String, attribute: { source: true }}) color?: ColorType;
  };

  return ColoredCmp;
}

Hotell added a commit that referenced this issue Mar 8, 2017
@Hotell Hotell mentioned this issue Mar 8, 2017
4 tasks
Hotell added a commit that referenced this issue Mar 9, 2017
Hotell added a commit that referenced this issue Mar 9, 2017
@Hotell Hotell closed this as completed in 47dab43 Mar 9, 2017
@Hotell Hotell self-assigned this Mar 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant