Skip to content

Commit 8d79e46

Browse files
committed
Switch from exclamation point to declare syntax for type-only properties
1 parent 1cc369e commit 8d79e46

File tree

11 files changed

+25
-25
lines changed

11 files changed

+25
-25
lines changed

src/blockview.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ export interface BlockView extends ContentView {
1616
export class LineView extends ContentView implements BlockView {
1717
children: ContentView[] = []
1818
length: number = 0
19-
dom!: HTMLElement | null
19+
declare dom: HTMLElement | null
2020
prevAttrs: Attrs | null | undefined = undefined
2121
attrs: Attrs | null = null
2222
breakAfter = 0
23-
parent!: DocView | null
23+
declare parent: DocView | null
2424

2525
// Consumes source
2626
merge(from: number, to: number, source: BlockView | null, hasStart: boolean, openStart: number, openEnd: number): boolean {
@@ -172,8 +172,8 @@ export class LineView extends ContentView implements BlockView {
172172
}
173173

174174
export class BlockWidgetView extends ContentView implements BlockView {
175-
dom!: HTMLElement | null
176-
parent!: DocView | null
175+
declare dom: HTMLElement | null
176+
declare parent: DocView | null
177177
breakAfter = 0
178178
prevWidget: WidgetType | null = null
179179

src/contentview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export abstract class ContentView {
3232
flags: number = ViewFlag.NodeDirty
3333
abstract length: number
3434
abstract children: ContentView[]
35-
breakAfter!: number
35+
declare breakAfter: number
3636

3737
get overrideDOMText(): Text | null { return null }
3838

src/decoration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export abstract class Decoration extends RangeValue {
214214
readonly spec: any) { super() }
215215

216216
/// @internal
217-
point!: boolean
217+
declare point: boolean
218218

219219
/// @internal
220220
get heightRelevant() { return false }

src/docview.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Composition = {
2222
}
2323

2424
export class DocView extends ContentView {
25-
children!: BlockView[]
25+
declare children: BlockView[]
2626

2727
decorations: readonly DecorationSet[] = []
2828
dynamicDecorationMap: boolean[] = [false]
@@ -49,7 +49,7 @@ export class DocView extends ContentView {
4949
impreciseHead: DOMPos | null = null
5050
forceSelection = false
5151

52-
dom!: HTMLElement
52+
declare dom: HTMLElement
5353

5454
// Used by the resize observer to ignore resizes that we caused
5555
// ourselves
@@ -572,7 +572,7 @@ export class DocView extends ContentView {
572572
}
573573

574574
// Will never be called but needs to be present
575-
split!: () => ContentView
575+
declare split: () => ContentView
576576
}
577577

578578
function betweenUneditable(pos: DOMPos) {

src/editorview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class EditorView {
145145
private announceDOM: HTMLElement
146146

147147
/// @internal
148-
inputState!: InputState
148+
declare inputState: InputState
149149

150150
/// @internal
151151
public viewState: ViewState
@@ -156,7 +156,7 @@ export class EditorView {
156156
private pluginMap: Map<ViewPlugin<any>, PluginInstance | null> = new Map
157157
private editorAttrs: Attrs = {}
158158
private contentAttrs: Attrs = {}
159-
private styleModules!: readonly StyleModule[]
159+
declare private styleModules: readonly StyleModule[]
160160
private bidiCache: CachedOrder[] = []
161161

162162
private destroyed = false;

src/gutter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export abstract class GutterMarker extends RangeValue {
2323

2424
/// This property can be used to add CSS classes to the gutter
2525
/// element that contains this marker.
26-
elementClass!: string
26+
declare elementClass: string
2727

2828
/// Called if the marker has a `toDOM` method and its representation
2929
/// was removed from a gutter.

src/heightmap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export abstract class HeightMap {
149149
public flags: number = Flag.Outdated
150150
) {}
151151

152-
size!: number
152+
declare size: number
153153

154154
get outdated() { return (this.flags & Flag.Outdated) > 0 }
155155
set outdated(value) { this.flags = (value ? Flag.Outdated : 0) | (this.flags & ~Flag.Outdated) }

src/inlineview.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {EditorView} from "./editorview"
99
const MaxJoinLen = 256
1010

1111
export class TextView extends ContentView {
12-
children!: ContentView[]
13-
dom!: Text | null
12+
declare children: ContentView[]
13+
declare dom: Text | null
1414

1515
constructor(public text: string) {
1616
super()
@@ -69,7 +69,7 @@ export class TextView extends ContentView {
6969
}
7070

7171
export class MarkView extends ContentView {
72-
dom!: HTMLElement | null
72+
declare dom: HTMLElement | null
7373

7474
constructor(readonly mark: MarkDecoration,
7575
public children: ContentView[] = [],
@@ -159,8 +159,8 @@ function textCoords(text: Text, pos: number, side: number): Rect | null {
159159

160160
// Also used for collapsed ranges that don't have a placeholder widget!
161161
export class WidgetView extends ContentView {
162-
children!: ContentView[]
163-
dom!: HTMLElement | null
162+
declare children: ContentView[]
163+
declare dom: HTMLElement | null
164164
prevWidget: WidgetType | null = null
165165

166166
static create(widget: WidgetType, length: number, side: number) {
@@ -256,8 +256,8 @@ export class WidgetView extends ContentView {
256256
// browser bugs that show up when the cursor is directly next to
257257
// uneditable inline content.
258258
export class WidgetBufferView extends ContentView {
259-
children!: ContentView[]
260-
dom!: HTMLElement | null
259+
declare children: ContentView[]
260+
declare dom: HTMLElement | null
261261

262262
constructor(readonly side: number) { super() }
263263

src/placeholder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function placeholder(content: string | HTMLElement | ((view: EditorView)
4848
: Decoration.none
4949
}
5050

51-
update!: () => void // Kludge to convince TypeScript that this is a plugin value
51+
declare update: () => void // Kludge to convince TypeScript that this is a plugin value
5252

5353
get decorations() { return this.view.state.doc.length ? Decoration.none : this.placeholder }
5454
}, {decorations: v => v.decorations})

src/tooltip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
141141
position: "fixed" | "absolute"
142142
madeAbsolute = false
143143
parent: HTMLElement | null
144-
container!: HTMLElement
144+
declare container: HTMLElement
145145
classes: string
146146
intersectionObserver: IntersectionObserver | null
147147
resizeObserver: ResizeObserver | null

0 commit comments

Comments
 (0)