Skip to content

Commit 26526d7

Browse files
committed
chore: Satisfy updated Typescript (4.8.2) & Prettier
1 parent c3c265b commit 26526d7

File tree

5 files changed

+13
-18
lines changed

5 files changed

+13
-18
lines changed

src/doc/createNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function createNode(
4848
value instanceof String ||
4949
value instanceof Number ||
5050
value instanceof Boolean ||
51-
(typeof BigInt === 'function' && value instanceof BigInt) // not supported everywhere
51+
(typeof BigInt !== 'undefined' && value instanceof BigInt) // not supported everywhere
5252
) {
5353
// https://tc39.es/ecma262/#sec-serializejsonproperty
5454
value = value.valueOf()

src/nodes/YAMLMap.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import { Pair } from './Pair.js'
99
import { isScalarValue, Scalar } from './Scalar.js'
1010
import type { ToJSContext } from './toJS.js'
1111

12+
export type MapLike =
13+
| Map<unknown, unknown>
14+
| Set<unknown>
15+
| Record<string | number | symbol, unknown>
16+
1217
export function findPair<K = unknown, V = unknown>(
1318
items: Iterable<Pair<K, V>>,
1419
key: unknown
@@ -105,7 +110,7 @@ export class YAMLMap<K = unknown, V = unknown> extends Collection {
105110
* @param {Class} Type - If set, forces the returned collection type
106111
* @returns Instance of Type, Map, or Object
107112
*/
108-
toJSON<T = unknown>(
113+
toJSON<T extends MapLike = Map<unknown, unknown>>(
109114
_?: unknown,
110115
ctx?: ToJSContext,
111116
Type?: { new (): T }

src/nodes/YAMLSeq.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,8 @@ export class YAMLSeq<T = unknown> extends Collection {
5858
*/
5959
get(key: unknown, keepScalar: true): Scalar<T> | undefined
6060
get(key: unknown, keepScalar?: false): T | undefined
61-
get(
62-
key: unknown,
63-
keepScalar?: boolean
64-
): T | Scalar<T> | undefined
65-
get(
66-
key: unknown,
67-
keepScalar?: boolean
68-
): T | Scalar<T> | undefined {
61+
get(key: unknown, keepScalar?: boolean): T | Scalar<T> | undefined
62+
get(key: unknown, keepScalar?: boolean): T | Scalar<T> | undefined {
6963
const idx = asItemIndex(key)
7064
if (typeof idx !== 'number') return undefined
7165
const it = this.items[idx]

src/nodes/addPairToJSMap.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ import { isAlias, isMap, isNode, isScalar, isSeq } from './Node.js'
44
import type { Pair } from './Pair.js'
55
import { Scalar } from './Scalar.js'
66
import { toJS, ToJSContext } from './toJS.js'
7+
import type { MapLike } from './YAMLMap.js'
78

89
const MERGE_KEY = '<<'
910

1011
export function addPairToJSMap(
1112
ctx: ToJSContext | undefined,
12-
map:
13-
| Map<unknown, unknown>
14-
| Set<unknown>
15-
| Record<string | number | symbol, unknown>,
13+
map: MapLike,
1614
{ key, value }: Pair
1715
) {
1816
if (ctx?.doc.schema.merge && isMergeKey(key)) {
@@ -58,10 +56,7 @@ const isMergeKey = (key: unknown) =>
5856
// later mapping nodes. -- http://yaml.org/type/merge.html
5957
function mergeToJSMap(
6058
ctx: ToJSContext | undefined,
61-
map:
62-
| Map<unknown, unknown>
63-
| Set<unknown>
64-
| Record<string | number | symbol, unknown>,
59+
map: MapLike,
6560
value: unknown
6661
) {
6762
const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value

src/schema/yaml-1.1/set.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class YAMLSet<T = unknown> extends YAMLMap<T, Scalar<null> | null> {
2424
let pair: Pair<T, Scalar<null> | null>
2525
if (isPair(key)) pair = key
2626
else if (
27+
key &&
2728
typeof key === 'object' &&
2829
'key' in key &&
2930
'value' in key &&

0 commit comments

Comments
 (0)