Skip to content

Commit 6a9af9a

Browse files
authored
Merge pull request #123 from atom-community/type-errors
2 parents 268324b + a46f99c commit 6a9af9a

File tree

7 files changed

+105
-44
lines changed

7 files changed

+105
-44
lines changed

lib/adapters/autocomplete-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
TextEditor,
2121
} from 'atom';
2222
import * as ac from 'atom/autocomplete-plus';
23-
import { Suggestion, TextSuggestion, SnippetSuggestion } from 'atom-ide';
23+
import { Suggestion, TextSuggestion, SnippetSuggestion } from '../types/autocomplete-extended';
2424

2525
/**
2626
* Holds a list of suggestions generated from the CompletionItem[]

lib/types/autocomplete-extended.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Autocomplete extention (the properties added by atom-languageclient)
2+
// See this PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/51284
3+
4+
import * as ac from 'atom/autocomplete-plus';
5+
6+
/** Adds LSP specific properties to the Atom SuggestionBase type */
7+
interface SuggestionBase extends ac.SuggestionBase {
8+
/**
9+
* A string that is used when filtering and sorting a set of
10+
* completion items with a prefix present. When `falsy` the
11+
* [displayText](#ac.SuggestionBase.displayText) is used. When
12+
* no prefix, the `sortText` property is used.
13+
*/
14+
filterText?: string;
15+
16+
/**
17+
* String representing the replacement prefix from the suggestion's
18+
* custom start point to the original buffer position the suggestion
19+
* was gathered from.
20+
*/
21+
customReplacmentPrefix?: string;
22+
}
23+
export type TextSuggestion = SuggestionBase & ac.TextSuggestion;
24+
export type SnippetSuggestion = SuggestionBase & ac.SnippetSuggestion;
25+
export type Suggestion = TextSuggestion | SnippetSuggestion;

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
"test.format": "prettier . --check",
1717
"lint": "eslint . --fix --ext .ts",
1818
"test.lint": "eslint . --ext .ts",
19-
"clean": "rimraf build",
20-
"compile": "tsc",
21-
"watch": "tsc -watch",
19+
"clean": "shx rm -rf build && mkdirp build",
20+
"copy.typings": "shx cp -r ./typings ./build",
21+
"compile": "npm run copy.typings && tsc",
22+
"watch": "npm run compile -- --watch",
2223
"prepare": "npm run clean && npm run compile",
2324
"test": "npm run compile && atom --test build/test"
2425
},
@@ -43,7 +44,7 @@
4344
"eslint": "^7.18.0",
4445
"mocha": "^8.2.1",
4546
"mocha-appveyor-reporter": "^0.4.2",
46-
"rimraf": "^3.0.2",
47+
"shx": "^0.3.3",
4748
"sinon": "^9.2.4",
4849
"typescript": "~4.1.3"
4950
}

pnpm-lock.yaml

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

test/adapters/autocomplete-adapter.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import * as ac from 'atom/autocomplete-plus';
1010
import { expect } from 'chai';
1111
import { createSpyConnection, createFakeEditor } from '../helpers.js';
12-
import { TextSuggestion, SnippetSuggestion } from 'atom-ide';
12+
import { TextSuggestion, SnippetSuggestion } from '../../lib/types/autocomplete-extended';
1313
import { CompletionItem, MarkupContent, InsertTextFormat, TextEdit, Command } from '../../lib/languageclient';
1414

1515
function createRequest({

tsconfig.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
"noFallthroughCasesInSwitch": true,
1313
"noImplicitReturns": true,
1414
"noUnusedLocals": true,
15-
"baseUrl": "./"
15+
"typeRoots": [
16+
"./node_modules/@types",
17+
"./typings"
18+
]
1619
},
1720
"include": [
18-
"typings/**/*.ts",
19-
"lib/**/*.ts",
20-
"test/**/*.ts"
21+
"typings",
22+
"lib",
23+
"test"
2124
]
2225
}

typings/atom-ide/index.d.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,4 @@
11
declare module 'atom-ide' {
2-
32
// atom-ide-base types for backward compatibility
43
export * from "atom-ide-base/types-packages/main"
5-
6-
// NotificationButton for backward compatibility (moved to "../../lib/adapters/notifications-adapter")
7-
export interface NotificationButton {
8-
text: string
9-
}
10-
11-
// Autocomplete extention (the properties added by atom-languageclient)
12-
// See this PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/51284
13-
14-
import * as ac from 'atom/autocomplete-plus';
15-
16-
/** Adds LSP specific properties to the Atom SuggestionBase type */
17-
interface SuggestionBase extends ac.SuggestionBase {
18-
/**
19-
* A string that is used when filtering and sorting a set of
20-
* completion items with a prefix present. When `falsy` the
21-
* [displayText](#ac.SuggestionBase.displayText) is used. When
22-
* no prefix, the `sortText` property is used.
23-
*/
24-
filterText?: string;
25-
26-
/**
27-
* String representing the replacement prefix from the suggestion's
28-
* custom start point to the original buffer position the suggestion
29-
* was gathered from.
30-
*/
31-
customReplacmentPrefix?: string;
32-
}
33-
export type TextSuggestion = SuggestionBase & ac.TextSuggestion;
34-
export type SnippetSuggestion = SuggestionBase & ac.SnippetSuggestion;
35-
export type Suggestion = TextSuggestion | SnippetSuggestion;
364
}

0 commit comments

Comments
 (0)