Skip to content

Commit f785ff4

Browse files
authored
Merge pull request #133 from lierdakil/cleanup-module-augments
refactor: clean-up module augments
2 parents 0c2154c + a67b6a9 commit f785ff4

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

lib/adapters/notifications-adapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ShowMessageParams,
66
ShowMessageRequestParams,
77
} from "../languageclient"
8-
import { Notification, NotificationOptions, NotificationExt } from "atom"
8+
import { Notification, NotificationOptions } from "atom"
99

1010
export interface NotificationButton {
1111
text: string
@@ -109,7 +109,7 @@ function addNotificationForMessage(
109109
message: string,
110110
options: NotificationOptions
111111
): Notification | null {
112-
function isDuplicate(note: NotificationExt): boolean {
112+
function isDuplicate(note: Notification): boolean {
113113
const noteDismissed = note.isDismissed && note.isDismissed()
114114
const noteOptions = (note.getOptions && note.getOptions()) || {}
115115
return (

lib/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { join, resolve } from "path"
22
import { existsSync } from "fs"
3-
import { Point, TextBuffer, TextEditor, TextEditorExt, Range, BufferScanResult } from "atom"
3+
import { Point, TextBuffer, TextEditor, Range, BufferScanResult } from "atom"
44
import { CancellationToken, CancellationTokenSource } from "vscode-jsonrpc"
55

66
export type ReportBusyWhile = <T>(title: string, f: () => Promise<T>) => Promise<T>
@@ -10,7 +10,7 @@ export type ReportBusyWhile = <T>(title: string, f: () => Promise<T>) => Promise
1010
* Uses the non-word characters from the position's grammar scope.
1111
*/
1212
export function getWordAtPosition(editor: TextEditor, position: Point): Range {
13-
const nonWordCharacters = escapeRegExp((editor as TextEditorExt).getNonWordCharacters(position))
13+
const nonWordCharacters = escapeRegExp(editor.getNonWordCharacters(position))
1414
const range = _getRegexpRangeAtPosition(
1515
editor.getBuffer(),
1616
position,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"devDependencies": {
3535
"@atom/mocha-test-runner": "^1.6.1",
36-
"@types/atom": "^1.40.9",
36+
"@types/atom": "^1.40.10",
3737
"@types/chai": "^4.2.14",
3838
"@types/mocha": "^8.2.0",
3939
"@types/node": "14.14.22",

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typings/atom/index.d.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
/* eslint-disable no-shadow, @typescript-eslint/no-unused-vars */
12
import { Point, Notification, NotificationOptions, TextEditor } from "atom"
23

3-
declare module "atom" {
4-
interface TextEditorExt extends TextEditor {
4+
// NOTE: due to a bug in how TypeScript resolves ambient augments,
5+
// need to be more specific here for TextEditor to keep its "class"
6+
// status and not be demoted to "interface". Should revert this
7+
// once the issue is fixed.
8+
declare module "atom/src/text-editor" {
9+
interface TextEditor {
510
getNonWordCharacters(position: Point): string
611
}
12+
}
713

14+
// NOTE: same here
15+
declare module "atom/src/notification" {
816
/** Non-public Notification api */
9-
interface NotificationExt extends Notification {
17+
interface Notification {
1018
isDismissed?: () => boolean
1119
getOptions?: () => NotificationOptions | null
1220
}

0 commit comments

Comments
 (0)