refactor: use flat options on class

This commit is contained in:
Evan You
2018-10-09 20:22:29 -04:00
parent b527705928
commit da6f0d7adc
9 changed files with 92 additions and 102 deletions

View File

@@ -9,6 +9,16 @@ interface ProviderProps {
}
export class Provide extends Component<ProviderProps> {
static props = {
id: {
type: [String, Symbol],
required: true
},
value: {
required: true
}
}
updateValue() {
// TS doesn't allow symbol as index :/
// https://github.com/Microsoft/TypeScript/issues/24587
@@ -43,18 +53,6 @@ export class Provide extends Component<ProviderProps> {
}
}
Provide.options = {
props: {
id: {
type: [String, Symbol],
required: true
},
value: {
required: true
}
}
}
export class Inject extends Component {
render(props: any, slots: any) {
return slots.default && slots.default(contextStore[props.id])

View File

@@ -114,7 +114,7 @@ export class KeepAlive extends Component<KeepAliveProps> {
;(KeepAlive as any)[KeepAliveSymbol] = true
function getName(comp: ComponentClass): string | void {
return comp.options && comp.options.name
return comp.displayName || comp.name
}
function matches(pattern: MatchPattern, name: string): boolean {