Skip to content

Commit 83ce34d

Browse files
committed
Switch from exclamation point to declare syntax for type-only properties
1 parent 64cba4b commit 83ce34d

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

src/change.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,9 @@ function composeSets(setA: ChangeDesc, setB: ChangeDesc, mkSet = false): ChangeD
529529

530530
class SectionIter {
531531
i = 0
532-
len!: number
533-
off!: number
534-
ins!: number
532+
declare len: number
533+
declare off: number
534+
declare ins: number
535535

536536
constructor(readonly set: ChangeDesc) {
537537
this.next()

src/facet.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class Facet<Input, Output = readonly Input[]> implements FacetReader<Outp
110110
return this.compute([field], state => get!(state.field(field)))
111111
}
112112

113-
tag!: Output
113+
declare tag: Output
114114
}
115115

116116
/// A facet reader can be used to fetch the value of a facet, through
@@ -138,7 +138,7 @@ const enum Provider { Static, Single, Multi }
138138

139139
class FacetProvider<Input> {
140140
readonly id = nextID++
141-
extension!: Extension // Kludge to convince the type system these count as extensions
141+
declare extension: Extension // Kludge to convince the type system these count as extensions
142142

143143
constructor(readonly dependencies: readonly Slot<any>[],
144144
readonly facet: Facet<Input, any>,
@@ -405,7 +405,7 @@ export const Prec = {
405405

406406
class PrecExtension {
407407
constructor(readonly inner: Extension, readonly prec: number) {}
408-
extension!: Extension
408+
declare extension: Extension
409409
}
410410

411411

@@ -438,7 +438,7 @@ export class Compartment {
438438

439439
export class CompartmentInstance {
440440
constructor(readonly compartment: Compartment, readonly inner: Extension) {}
441-
extension!: Extension
441+
declare extension: Extension
442442
}
443443

444444
export interface DynamicSlot {

src/rangeset.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ export abstract class RangeValue {
1212
/// The bias value at the start of the range. Determines how the
1313
/// range is positioned relative to other ranges starting at this
1414
/// position. Defaults to 0.
15-
startSide!: number
15+
declare startSide: number
1616
/// The bias value at the end of the range. Defaults to 0.
17-
endSide!: number
17+
declare endSide: number
1818

1919
/// The mode with which the location of the range should be mapped
2020
/// when its `from` and `to` are the same, to decide whether a
2121
/// change deletes the range. Defaults to `MapMode.TrackDel`.
22-
mapMode!: MapMode
22+
declare mapMode: MapMode
2323
/// Determines whether this value marks a point range. Regular
2424
/// ranges affect the part of the document they cover, and are
2525
/// meaningless when empty. Point ranges have a meaning on their
2626
/// own. When non-empty, a point range is treated as atomic and
2727
/// shadows any ranges contained in it.
28-
point!: boolean
28+
declare point: boolean
2929

3030
/// Create a [range](#state.Range) with this value.
3131
range(from: number, to = from) { return Range.create(from, to, this) }
@@ -540,12 +540,12 @@ function findSharedChunks(a: readonly RangeSet<any>[], b: readonly RangeSet<any>
540540
}
541541

542542
class LayerCursor<T extends RangeValue> {
543-
from!: number
544-
to!: number
545-
value!: T | null
543+
declare from: number
544+
declare to: number
545+
declare value: T | null
546546

547-
chunkIndex!: number
548-
rangeIndex!: number
547+
declare chunkIndex: number
548+
declare rangeIndex: number
549549

550550
constructor(readonly layer: RangeSet<T>,
551551
readonly skip: Set<Chunk<T>> | null,
@@ -626,10 +626,10 @@ class LayerCursor<T extends RangeValue> {
626626
}
627627

628628
class HeapCursor<T extends RangeValue> {
629-
from!: number
630-
to!: number
631-
value!: T | null
632-
rank!: number
629+
declare from: number
630+
declare to: number
631+
declare value: T | null
632+
declare rank: number
633633

634634
constructor(readonly heap: LayerCursor<T>[]) {}
635635

src/text.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export abstract class Text implements Iterable<string> {
147147
abstract readonly children: readonly Text[] | null
148148

149149
/// @hide
150-
[Symbol.iterator]!: () => Iterator<string>
150+
declare [Symbol.iterator]: () => Iterator<string>
151151

152152
/// Create a `Text` instance for the given array of lines.
153153
static of(text: readonly string[]): Text {
@@ -469,7 +469,7 @@ class RawTextCursor implements TextIterator {
469469
}
470470

471471
/// @internal
472-
[Symbol.iterator]!: () => Iterator<string>
472+
declare [Symbol.iterator]: () => Iterator<string>
473473
}
474474

475475
class PartialTextCursor implements TextIterator {
@@ -513,7 +513,7 @@ class PartialTextCursor implements TextIterator {
513513
get lineBreak() { return this.cursor.lineBreak && this.value != "" }
514514

515515
/// @internal
516-
[Symbol.iterator]!: () => Iterator<string>
516+
declare [Symbol.iterator]: () => Iterator<string>
517517
}
518518

519519
class LineCursor implements TextIterator {
@@ -548,7 +548,7 @@ class LineCursor implements TextIterator {
548548
get lineBreak() { return false }
549549

550550
/// @internal
551-
[Symbol.iterator]!: () => Iterator<string>
551+
declare [Symbol.iterator]: () => Iterator<string>
552552
}
553553

554554
if (typeof Symbol != "undefined") {

src/transaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class Annotation<T> {
2626

2727
// This is just to get less sloppy typing (where StateEffect is a subtype of Annotation)
2828
// @ts-ignore
29-
private _isAnnotation!: true
29+
declare private _isAnnotation: true
3030
}
3131

3232
/// Marker that identifies a type of [annotation](#state.Annotation).

0 commit comments

Comments
 (0)