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

Update TypeScript to 3.8.3 and Prettier to 2.0.4 #248

Merged
merged 3 commits into from
May 4, 2020
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- 8
- 10
cache:
directories:
- node_modules
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
"lodash.clonedeepwith": "*",
"lodash.intersection": "*",
"mobx": "^5.14.0",
"prettier": "^1.7.2",
"prettier": "^2.0.4",
"rollup": "^0.50.0",
"rxjs": "^6.0.0",
"shelljs": "^0.8.3",
"ts-jest": "^24.0.2",
"typescript": "3.6.4"
"typescript": "^3.8.3"
},
"dependencies": {},
"peerDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const readline = require("readline")

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
output: process.stdout,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be the result of using a different prettier config or version. Please align your local settings with this repo, or don't stage the unrelated files, or creating a PR that locks the config and prettier version would be even more awsome!

})

function run(command, options) {
Expand All @@ -26,8 +26,8 @@ function exit(code, msg) {
}

async function prompt(question, defaultValue) {
return new Promise(resolve => {
rl.question(`${question} [${defaultValue}]: `, answer => {
return new Promise((resolve) => {
rl.question(`${question} [${defaultValue}]: `, (answer) => {
answer = answer && answer.trim()
resolve(answer ? answer : defaultValue)
})
Expand All @@ -51,7 +51,7 @@ async function main() {
// Check registry data
const npmInfoRet = run(`npm info ${pkg.name} --json`, {
continueOnErrors: true,
silent: true
silent: true,
})
if (npmInfoRet.code === 0) {
//package is registered in npm?
Expand Down Expand Up @@ -81,6 +81,6 @@ async function main() {
}
}

main().catch(e => {
main().catch((e) => {
throw e
})
8 changes: 4 additions & 4 deletions src/action-async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let inOrderExecution: () => Promise<void>
}

const idle = () =>
new Promise(r => {
new Promise((r) => {
queueMicrotaskPolyfill(r)
})

Expand Down Expand Up @@ -93,7 +93,7 @@ export async function task<R>(value: R | PromiseLike<R>): Promise<R> {
actionRunInfo,
actionName,
args,
scope
scope,
})
currentlyActiveIds.add(runId)
}
Expand Down Expand Up @@ -205,7 +205,7 @@ function actionAsyncFn(actionName: string, fn: Function): Function {
if (typeof actionName !== "string" || !actionName)
fail(`actions should have valid names, got: '${actionName}'`)

return async function(this: any, ...args: any) {
return async function (this: any, ...args: any) {
const nextRunId = runId++
unfinishedIds.add(nextRunId)

Expand All @@ -217,7 +217,7 @@ function actionAsyncFn(actionName: string, fn: Function): Function {
actionRunInfo,
actionName,
args,
scope: this
scope: this,
})
currentlyActiveIds.add(nextRunId)

Expand Down
4 changes: 2 additions & 2 deletions src/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export function moveItem<T>(target: IObservableArray<T>, fromIndex: number, toIn
...oldItems.slice(0, fromIndex),
...oldItems.slice(fromIndex + 1, toIndex + 1),
oldItems[fromIndex],
...oldItems.slice(toIndex + 1)
...oldItems.slice(toIndex + 1),
]
} else {
// toIndex < fromIndex
newItems = [
...oldItems.slice(0, toIndex),
oldItems[fromIndex],
...oldItems.slice(toIndex, fromIndex),
...oldItems.slice(fromIndex + 1)
...oldItems.slice(fromIndex + 1),
]
}
target.replace(newItems)
Expand Down
6 changes: 3 additions & 3 deletions src/async-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,16 @@ export function asyncAction(arg1: any, arg2?: any): any {
const descriptor: PropertyDescriptor = arguments[2]
if (descriptor && descriptor.value) {
return Object.assign({}, descriptor, {
value: flow(descriptor.value)
value: flow(descriptor.value),
})
} else {
return Object.assign({}, descriptor, {
set(v: any) {
Object.defineProperty(this, name, {
...descriptor,
value: flow(v)
value: flow(v),
})
}
},
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/computedFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
computed,
onBecomeUnobserved,
_isComputingDerivation,
isAction
isAction,
} from "mobx"

/**
Expand Down Expand Up @@ -56,7 +56,7 @@ export function computedFn<T extends (...args: any[]) => any>(
: keepAliveOrOptions
const d = new DeepMap<IComputedValue<any>>()

return function(...args: Parameters<T>): ReturnType<T> {
return function (...args: Parameters<T>): ReturnType<T> {
const self = this
const entry = d.entry(args)
// cache hit, return
Expand All @@ -78,7 +78,7 @@ export function computedFn<T extends (...args: any[]) => any>(
},
{
...opts,
name: `computedFn(${fn.name}#${++i})`
name: `computedFn(${fn.name}#${++i})`,
}
)
entry.set(c)
Expand Down
4 changes: 2 additions & 2 deletions src/create-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
onBecomeUnobserved,
IComputedValue,
_isComputingDerivation,
IComputedValueOptions
IComputedValueOptions,
} from "mobx"
import { invariant, addHiddenProp } from "./utils"

Expand Down Expand Up @@ -75,7 +75,7 @@ export function createTransformer<A, B>(
},
{
...computedValueOptions,
name: prettifiedName
name: prettifiedName,
}
)
if (!keepAlive) {
Expand Down
4 changes: 2 additions & 2 deletions src/create-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
computed,
keys,
_getAdministration,
$mobx
$mobx,
} from "mobx"
import { invariant, getAllMethodsAndProperties } from "./utils"

Expand Down Expand Up @@ -75,7 +75,7 @@ export class ViewModel<T> implements IViewModel<T> {
} else {
this.localValues.delete(key)
}
})
}),
})
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/decorator-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function decorateMethod(
value: decorateFn(prop, descriptor.value),
enumerable: false,
configurable: true, // See #1477
writable: true // for typescript, this must be writable, otherwise it cannot inherit :/ (see inheritable actions test)
writable: true, // for typescript, this must be writable, otherwise it cannot inherit :/ (see inheritable actions test)
}
}

Expand All @@ -47,7 +47,7 @@ export function decorateMethod(
initializer() {
// N.B: we can't immediately invoke initializer; this would be wrong
return decorateFn(prop, initializer!.call(this))
}
},
}
}

Expand All @@ -65,6 +65,6 @@ export function decorateField(
},
set(value) {
addHiddenProp(this, prop, decorateFn(prop, value))
}
},
})
}
4 changes: 2 additions & 2 deletions src/deepObserve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
IArraySplice,
IMapDidChange,
values,
entries
entries,
} from "mobx"
import { IDisposer } from "./utils"

Expand Down Expand Up @@ -117,7 +117,7 @@ export function deepObserve<T = any>(
const entry = {
parent,
path,
dispose: observe(thing, genericListener)
dispose: observe(thing, genericListener),
}
entrySet.set(thing, entry)
entries(thing).forEach(([key, value]) => observeRecursively(value, entry, key))
Expand Down
6 changes: 3 additions & 3 deletions src/from-promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function createObservablePromise(origPromise: any, oldPromise?: any) {
promise,
{
value: oldData,
state: PENDING
state: PENDING,
},
{},
{ deep: false }
Expand Down Expand Up @@ -195,14 +195,14 @@ export const fromPromise: {
resolve<T>(value?: T): IFulfilledPromise<T> & IBasePromiseBasedObservable<T>
} = createObservablePromise as any

fromPromise.reject = action("fromPromise.reject", function(reason: any) {
fromPromise.reject = action("fromPromise.reject", function (reason: any) {
const p: any = fromPromise(Promise.reject(reason))
p.state = REJECTED
p.value = reason
return p
}) as any

fromPromise.resolve = action("fromPromise.resolve", function(value: any = undefined) {
fromPromise.resolve = action("fromPromise.resolve", function (value: any = undefined) {
const p: any = fromPromise(Promise.resolve(value))
p.state = FULFILLED
p.value = value
Expand Down
2 changes: 1 addition & 1 deletion src/from-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ export function fromResource<T>(
isDisposed = true
suspender()
},
isAlive: () => isActive
isAlive: () => isActive,
}
}
2 changes: 1 addition & 1 deletion src/guarded-when.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ export function whenWithTimeout(
deprecated("whenWithTimeout is deprecated, use mobx.when with timeout option instead")
return when(expr, action, {
timeout,
onError: onTimeout
onError: onTimeout,
})
}
2 changes: 1 addition & 1 deletion src/lazy-observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ export function lazyObservable<T>(
},
get pending() {
return pending.get()
}
},
}
}
4 changes: 2 additions & 2 deletions src/now.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function now(interval: number | "frame" = 1000) {
function createIntervalTicker(interval: number): IResource<number> {
let subscriptionHandle: any
return fromResource<number>(
sink => {
(sink) => {
subscriptionHandle = setInterval(() => sink(Date.now()), interval)
},
() => {
Expand All @@ -59,7 +59,7 @@ function createIntervalTicker(interval: number): IResource<number> {
function createAnimationFrameTicker(): IResource<number> {
let subscriptionHandle: number
const frameBasedTicker = fromResource<number>(
sink => {
(sink) => {
function scheduleTick() {
window.requestAnimationFrame(() => {
sink(Date.now())
Expand Down
4 changes: 2 additions & 2 deletions src/observable-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ export function toStream<T>(
? ({ newValue }: { newValue: T }) => observer(newValue)
: ({ newValue }: { newValue: T }) => observer.next(newValue),
fireImmediately
)
),
}
},
[observableSymbol()]: self
[observableSymbol()]: self,
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function addHiddenProp(object: any, propName: string, value: any) {
enumerable: false,
writable: true,
configurable: true,
value
value,
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/when-async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ import { deprecated } from "./utils"
export function whenAsync(fn: () => boolean, timeout: number = 0): Promise<void> {
deprecated("whenAsync is deprecated, use mobx.when without effect instead")
return when(fn, {
timeout
timeout,
})
}
Loading