Skip to content

Commit 199c3df

Browse files
committed
type fixes
1 parent d3594c8 commit 199c3df

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@
278278
"test": "c8 --check-coverage --lines 100 --branches 100 --functions 100 --statements 100 node --unhandled-rejections=strict ./src/test.js --repetition-time 50",
279279
"test-inspect": "node --inspect-brk --unhandled-rejections=strict ./src/test.js --repetition-time 50",
280280
"test-extensive": "c8 --check-coverage --lines 100 --branches 100 --functions 100 --statements 100 node ./src/test.js --repetition-time 30000 --extensive",
281-
"test:bundle": "esbuild bundle.test.js --bundle --outfile=dist/bundle.test.js --analyze && wc -c dist/bundle.test.js",
281+
"test:bundle": "esbuild bundle.test.js --bundle --outfile=dist/bundle.test.js --analyze --minify && wc -c dist/bundle.test.js",
282282
"trace-deopt": "clear && node --trace-deopt src/test.js",
283283
"trace-opt": "clear && node --trace-opt src/test.js",
284284
"lint": "standard && tsc",

src/bundle.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { map } from './index.js'
1+
import * as delta from 'lib0/delta'
22

3-
console.log(map.all(new Map(), x => x === 1))
3+
console.log(delta.create().toJSON())

src/delta/delta.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ export class SetAttrOp {
691691

692692
/**
693693
* @template [V=any]
694-
* @template {string|number} [K=string]
694+
* @template {string|number} [K=string|number]
695695
*/
696696
export class DeleteAttrOp {
697697
/**
@@ -845,7 +845,7 @@ export const $anyOp = s.$union($insertOp, $deleteOp, $textOp, $modifyOp)
845845

846846
export const $setAttrOp = /** @type {s.Schema<SetAttrOp<any>>} */ (s.$type('setAttrOp'))
847847
export const $modifyAttrOp = /** @type {s.Schema<ModifyAttrOp<any,string|number>>} */ (s.$type('modifyAttrOp'))
848-
export const $deleteAttrOp = /** @type {s.Schema<DeleteAttrOp<{},string|number>>} */ (s.$type('deleteAttrOp'))
848+
export const $deleteAttrOp = /** @type {s.Schema<DeleteAttrOp<any,string|number>>} */ (s.$type('deleteAttrOp'))
849849
export const $anyAttrOp = s.$union($setAttrOp, $deleteAttrOp, $modifyAttrOp)
850850

851851
/**
@@ -1000,7 +1000,7 @@ class DeltaData {
10001000

10011001
/**
10021002
* @type {list.List<
1003-
* | (Text extends true ? (RetainOp|TextOp|DeleteOp<{}>) : never)
1003+
* | (Text extends true ? (RetainOp|TextOp|DeleteOp<any>) : never)
10041004
* | (RetainOp|InsertOp<Children>|DeleteOp<any>|(Delta extends Children ? ModifyOp<Extract<Children,Delta>> : never))
10051005
* >}
10061006
*/
@@ -1430,7 +1430,7 @@ export class DeltaBuilder extends Delta {
14301430
* @param {Attribution?} attribution
14311431
* @return {DeltaBuilder<DeltaConfOverwrite<
14321432
* DConf,
1433-
* { attrs: MergeAttrs<Attrs,NewAttrs> }
1433+
* { attrs: MergeAttrs<DeltaConfGetAttrs<DConf>,NewAttrs> }
14341434
* >>
14351435
* }
14361436
*/

src/ts.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,11 @@
2929
* @template B
3030
* @typedef {A} AssertExtends
3131
*/
32+
33+
/**
34+
* In typescript `keyof {[k:string]:any}` is `string|number` instead of `string`. This KeyOf type returns the expected
35+
* result. Use this for pretty-printing onyly.
36+
*
37+
* @template {{[K:string|number|symbol]:any}} Obj
38+
* @typedef {{ [K in keyof Obj]: K }[keyof Obj]} KeyOf
39+
*/

0 commit comments

Comments
 (0)