Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decorate: Allow modifier when strict (MobX 4) #1712

Merged
merged 1 commit into from
Sep 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/api/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ export interface IActionFactory {
<T extends Function>(name: string, fn: T): T & IAction

// named decorator
(customName: string): (target: Object, key: string, baseDescriptor?: PropertyDescriptor) => void
(customName: string): (target: Object, key: string | symbol, baseDescriptor?: PropertyDescriptor) => void

// unnamed decorator
(target: Object, propertyKey: string, descriptor?: PropertyDescriptor): void
(target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): void

// @action.bound decorator
bound(target: Object, propertyKey: string, descriptor?: PropertyDescriptor): void
bound(target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): void
}

export var action: IActionFactory = function action(arg1, arg2?, arg3?, arg4?): any {
Expand Down
2 changes: 1 addition & 1 deletion src/api/observabledecorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IEnhancer } from "../types/modifiers"
import { createPropDecorator, BabelDescriptor } from "../utils/decorators2"

export type IObservableDecorator = {
(target: Object, property: string, descriptor?: PropertyDescriptor): void
(target: Object, property: string | symbol, descriptor?: PropertyDescriptor): void
enhancer: IEnhancer<any>
}

Expand Down
3 changes: 2 additions & 1 deletion test/base/decorate.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test("decorate should work", function() {
}

decorate(Box, {
uninitialized: observable,
uninitialized: observable.ref,
undeclared: observable,
height: observable,
sizes: observable,
Expand Down Expand Up @@ -97,6 +97,7 @@ test("decorate should work", function() {

test("decorate should work with plain object", function() {
const box = {
/** @type {boolean | undefined} */
uninitialized: undefined,
height: 20,
sizes: [2],
Expand Down