Fix selection visible property declaration #22

Closed
ilucin wants to merge 1 commit from master into master
ilucin commented 2023-03-20 14:08:59 +01:00 (Migrated from github.com)

The usage of ! in property declaration causes inconsistent TS compiler output, depending on the useDefineForClassFields compiler flag. If the useDefineForClassFields flag is true - selection.visible property will resolve to undefined, as the prototype value is being overwritten in the class constructor.

Since the ! is here only to declare that the property exists, and not to assume not-nullness -> it would be more appropriate to use declare statement instead. This is also a prevention of a future problem when TS switches to useDefineForClassFields as a default compiler behavior.

The usage of `!` in property declaration causes inconsistent TS compiler output, depending on the `useDefineForClassFields` compiler flag. If the `useDefineForClassFields` flag is `true` - `selection.visible` property will resolve to `undefined`, as the prototype value is being overwritten in the class constructor. Since the `!` is here only to declare that the property exists, and not to assume not-nullness -> it would be more appropriate to use `declare` statement instead. This is also a prevention of a future problem when TS switches to `useDefineForClassFields` as a default compiler behavior.
marijnh commented 2023-03-21 09:06:18 +01:00 (Migrated from github.com)

Fortunately, this code isn't being compiled with useDefineForClassFields: true, so there is no need to make this change.

Fortunately, this code isn't being compiled with `useDefineForClassFields: true`, so there is no need to make this change.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prosemirror/prosemirror-state!22
No description provided.