Skip to content

Commit

Permalink
More types
Browse files Browse the repository at this point in the history
Related: #1225
  • Loading branch information
ssbarnea committed Apr 25, 2024
1 parent 752891a commit 3ff92cd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
isPlaybook,
} from "../utils/yaml";
import { getVarsCompletion } from "./completionProviderUtils";
import { HostType } from "../services/ansibleInventory";

const priorityMap = {
nameKeyword: 1,
Expand Down Expand Up @@ -480,7 +481,7 @@ function getKeywordCompletion(
});
}

function getHostCompletion(hostObjectList): CompletionItem[] {
function getHostCompletion(hostObjectList: HostType[]): CompletionItem[] {
return hostObjectList.map(({ host, priority }) => {
const completionItem: CompletionItem = {
label: host,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { WorkspaceFolderContext } from "./workspaceManager";
import { CommandRunner } from "../utils/commandRunner";
import { URI } from "vscode-uri";

type HostType = { host: string; priority: number };
export type HostType = { host: string; priority: number };

type inventoryHostEntry = {
children: string[];
Expand Down
7 changes: 4 additions & 3 deletions packages/ansible-language-server/src/utils/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Pair,
parseDocument,
ParseOptions,
Schema,
SchemaOptions,
YAMLMap,
YAMLSeq,
Expand Down Expand Up @@ -45,7 +46,7 @@ export class AncestryBuilder<N extends Node | Pair = Node> {
* up.
*/
parent<X extends Node | Pair>(
type?: new (...args: unknown[]) => X,
type?: new (...args: Schema[]) => X,
): AncestryBuilder<X> {
this._index--;
if (isPair(this.get())) {
Expand Down Expand Up @@ -313,7 +314,7 @@ function getDeclaredCollectionsForMap(playNode: YAMLMap | null): string[] {
if (isSeq(collectionsNode)) {
for (const collectionNode of collectionsNode.items) {
if (isScalar(collectionNode)) {
declaredCollections.push(collectionNode.value.toString());
declaredCollections.push(String(collectionNode.value));
}
}
}
Expand Down Expand Up @@ -565,7 +566,7 @@ export function isPlaybook(textDocument: TextDocument): boolean {
return false;
}

const playbookKeysSet = new Set();
const playbookKeysSet: Set<string> = new Set();
const playbookJSON = path[0].toJSON();

Object.keys(playbookJSON).forEach(function (key) {
Expand Down
6 changes: 2 additions & 4 deletions packages/ansible-language-server/test/rootMochaHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ export const mochaHooks = (): Mocha.RootHookObject => {
consoleOutput.capture();
},

afterEach() {
if (this.currentTest.state !== "passed") {
consoleOutput.release();
}
afterEach(this: Mocha.Context) {
console.log(this.currentTest?.title);
},
};
};
2 changes: 1 addition & 1 deletion packages/ansible-language-server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
// "strict": true,
"strict": true,
"declaration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
Expand Down

0 comments on commit 3ff92cd

Please sign in to comment.