Change all typeof x === 'undefined' to
x === undefined`
https://github.com/theatre-js/theatre/pull/118#discussion_r846634374
This commit is contained in:
parent
f3dfb7cedb
commit
b2714ca876
6 changed files with 9 additions and 9 deletions
|
@ -164,7 +164,7 @@ export default class SheetObject implements IdentityDerivationProvider {
|
||||||
const leftDeserialized = deserializeAndSanitize(triple.left)
|
const leftDeserialized = deserializeAndSanitize(triple.left)
|
||||||
|
|
||||||
const left =
|
const left =
|
||||||
typeof leftDeserialized === 'undefined'
|
leftDeserialized === undefined
|
||||||
? propConfig.default
|
? propConfig.default
|
||||||
: leftDeserialized
|
: leftDeserialized
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ export default class SheetObject implements IdentityDerivationProvider {
|
||||||
|
|
||||||
const rightDeserialized = deserializeAndSanitize(triple.right)
|
const rightDeserialized = deserializeAndSanitize(triple.right)
|
||||||
const right =
|
const right =
|
||||||
typeof rightDeserialized === 'undefined'
|
rightDeserialized === undefined
|
||||||
? propConfig.default
|
? propConfig.default
|
||||||
: rightDeserialized
|
: rightDeserialized
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ export function getPropConfigByPath(
|
||||||
): undefined | PropTypeConfig {
|
): undefined | PropTypeConfig {
|
||||||
if (!parentConf) return undefined
|
if (!parentConf) return undefined
|
||||||
const [key, ...rest] = path
|
const [key, ...rest] = path
|
||||||
if (typeof key === 'undefined') return parentConf
|
if (key === undefined) return parentConf
|
||||||
if (!isPropConfigComposite(parentConf)) return undefined
|
if (!isPropConfigComposite(parentConf)) return undefined
|
||||||
|
|
||||||
const sub =
|
const sub =
|
||||||
|
@ -44,7 +44,7 @@ export function valueInProp<PropConfig extends PropTypeConfig_AllNonCompounds>(
|
||||||
? T
|
? T
|
||||||
: never {
|
: never {
|
||||||
const sanitizedVal = propConfig.deserializeAndSanitize(value)
|
const sanitizedVal = propConfig.deserializeAndSanitize(value)
|
||||||
if (typeof sanitizedVal === 'undefined') {
|
if (sanitizedVal === undefined) {
|
||||||
return propConfig.default
|
return propConfig.default
|
||||||
} else {
|
} else {
|
||||||
return sanitizedVal
|
return sanitizedVal
|
||||||
|
|
|
@ -24,7 +24,7 @@ export default function deepMergeWithCache<T extends SerializableMap>(
|
||||||
merged[key] =
|
merged[key] =
|
||||||
typeof valueInOverride === 'object' && typeof valueInBase === 'object'
|
typeof valueInOverride === 'object' && typeof valueInBase === 'object'
|
||||||
? deepMergeWithCache(valueInBase, valueInOverride, cache)
|
? deepMergeWithCache(valueInBase, valueInOverride, cache)
|
||||||
: typeof valueInOverride === 'undefined'
|
: valueInOverride === undefined
|
||||||
? valueInBase
|
? valueInBase
|
||||||
: valueInOverride
|
: valueInOverride
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ export default function forEachDeep<
|
||||||
for (const [key, value] of Object.entries(m)) {
|
for (const [key, value] of Object.entries(m)) {
|
||||||
forEachDeep(value!, fn, [...startingPath, key])
|
forEachDeep(value!, fn, [...startingPath, key])
|
||||||
}
|
}
|
||||||
} else if (typeof m === 'undefined' || m === null) {
|
} else if (m === undefined || m === null) {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
fn(m as $IntentionalAny as Primitive, startingPath)
|
fn(m as $IntentionalAny as Primitive, startingPath)
|
||||||
|
|
|
@ -100,14 +100,14 @@ export default function createTransactionPrivateApi(
|
||||||
propConfig: PropTypeConfig_AllNonCompounds,
|
propConfig: PropTypeConfig_AllNonCompounds,
|
||||||
path: PathToProp,
|
path: PathToProp,
|
||||||
) => {
|
) => {
|
||||||
if (typeof value === 'undefined' || value === null) {
|
if (value === undefined || value === null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const deserialized = cloneDeepSerializable(
|
const deserialized = cloneDeepSerializable(
|
||||||
propConfig.deserializeAndSanitize(value),
|
propConfig.deserializeAndSanitize(value),
|
||||||
)
|
)
|
||||||
if (typeof deserialized === 'undefined') {
|
if (deserialized === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Invalid value ${userReadableTypeOfValue(
|
`Invalid value ${userReadableTypeOfValue(
|
||||||
value,
|
value,
|
||||||
|
|
|
@ -58,7 +58,7 @@ export const setDrafts__onlyMeantToBeCalledByTransaction = (
|
||||||
let currentDrafts: undefined | Drafts
|
let currentDrafts: undefined | Drafts
|
||||||
|
|
||||||
const drafts = (): Drafts => {
|
const drafts = (): Drafts => {
|
||||||
if (typeof currentDrafts === 'undefined') {
|
if (currentDrafts === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Calling stateEditors outside of a transaction is not allowed.`,
|
`Calling stateEditors outside of a transaction is not allowed.`,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue