Skip to content

Commit 2fdfda3

Browse files
committed
updates to typing etc
1 parent 9727af9 commit 2fdfda3

File tree

3 files changed

+55
-25
lines changed

3 files changed

+55
-25
lines changed

src/client/ioc/container.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ export class ServiceContainer implements IServiceContainer {
2929
name?: string | number | symbol | undefined,
3030
): T[] {
3131
return name
32-
? this.container.getAllNamed<T>(serviceIdentifier, name)
33-
: this.container.getAll<T>(serviceIdentifier);
32+
? this.container.getAllNamed<T>(serviceIdentifier as interfaces.ServiceIdentifier<T>, name)
33+
: this.container.getAll<T>(serviceIdentifier as interfaces.ServiceIdentifier<T>);
3434
}
3535

3636
public tryGet<T>(

src/client/ioc/serviceManager.ts

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ export class ServiceManager implements IServiceManager {
1919
bindings?: symbol[],
2020
): void {
2121
if (name) {
22-
this.container.bind<T>(serviceIdentifier).to(constructor).whenTargetNamed(name);
22+
this.container
23+
.bind<T>(serviceIdentifier as interfaces.ServiceIdentifier<T>)
24+
.to(constructor)
25+
.whenTargetNamed(name);
2326
} else {
24-
this.container.bind<T>(serviceIdentifier).to(constructor);
27+
this.container.bind<T>(serviceIdentifier as interfaces.ServiceIdentifier<T>).to(constructor);
2528
}
2629

2730
if (bindings) {
@@ -39,7 +42,9 @@ export class ServiceManager implements IServiceManager {
3942
}
4043

4144
public addBinding<T1, T2>(from: identifier<T1>, to: identifier<T2>): void {
42-
this.container.bind(to).toService(from);
45+
this.container
46+
.bind<T2>(to as interfaces.ServiceIdentifier<T2>)
47+
.toService(from as interfaces.ServiceIdentifier<T1>);
4348
}
4449

4550
public addSingleton<T>(
@@ -51,9 +56,16 @@ export class ServiceManager implements IServiceManager {
5156
bindings?: symbol[],
5257
): void {
5358
if (name) {
54-
this.container.bind<T>(serviceIdentifier).to(constructor).inSingletonScope().whenTargetNamed(name);
59+
this.container
60+
.bind<T>(serviceIdentifier as interfaces.ServiceIdentifier<T>)
61+
.to(constructor)
62+
.inSingletonScope()
63+
.whenTargetNamed(name);
5564
} else {
56-
this.container.bind<T>(serviceIdentifier).to(constructor).inSingletonScope();
65+
this.container
66+
.bind<T>(serviceIdentifier as interfaces.ServiceIdentifier<T>)
67+
.to(constructor)
68+
.inSingletonScope();
5769
}
5870

5971
if (bindings) {
@@ -69,21 +81,26 @@ export class ServiceManager implements IServiceManager {
6981
name?: string | number | symbol | undefined,
7082
): void {
7183
if (name) {
72-
this.container.bind<T>(serviceIdentifier).toConstantValue(instance).whenTargetNamed(name);
84+
this.container
85+
.bind<T>(serviceIdentifier as interfaces.ServiceIdentifier<T>)
86+
.toConstantValue(instance)
87+
.whenTargetNamed(name);
7388
} else {
74-
this.container.bind<T>(serviceIdentifier).toConstantValue(instance);
89+
this.container.bind<T>(serviceIdentifier as interfaces.ServiceIdentifier<T>).toConstantValue(instance);
7590
}
7691
}
7792

7893
public get<T>(serviceIdentifier: identifier<T>, name?: string | number | symbol | undefined): T {
79-
return name ? this.container.getNamed<T>(serviceIdentifier, name) : this.container.get<T>(serviceIdentifier);
94+
return name
95+
? this.container.getNamed<T>(serviceIdentifier as interfaces.ServiceIdentifier<T>, name)
96+
: this.container.get<T>(serviceIdentifier as interfaces.ServiceIdentifier<T>);
8097
}
8198

8299
public tryGet<T>(serviceIdentifier: identifier<T>, name?: string | number | symbol | undefined): T | undefined {
83100
try {
84101
return name
85-
? this.container.getNamed<T>(serviceIdentifier, name)
86-
: this.container.get<T>(serviceIdentifier);
102+
? this.container.getNamed<T>(serviceIdentifier as interfaces.ServiceIdentifier<T>, name)
103+
: this.container.get<T>(serviceIdentifier as interfaces.ServiceIdentifier<T>);
87104
} catch {
88105
// This might happen after the container has been destroyed
89106
}
@@ -93,8 +110,8 @@ export class ServiceManager implements IServiceManager {
93110

94111
public getAll<T>(serviceIdentifier: identifier<T>, name?: string | number | symbol | undefined): T[] {
95112
return name
96-
? this.container.getAllNamed<T>(serviceIdentifier, name)
97-
: this.container.getAll<T>(serviceIdentifier);
113+
? this.container.getAllNamed<T>(serviceIdentifier as interfaces.ServiceIdentifier<T>, name)
114+
: this.container.getAll<T>(serviceIdentifier as interfaces.ServiceIdentifier<T>);
98115
}
99116

100117
public rebind<T>(

src/test/mocks/vsc/extHostedTypes.ts

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,12 @@ export class Selection extends Range {
450450
}
451451

452452
toJSON(): [Position, Position] {
453-
return ({
453+
return {
454454
start: this.start,
455455
end: this.end,
456456
active: this.active,
457457
anchor: this.anchor,
458-
} as unknown) as [Position, Position];
458+
} as unknown as [Position, Position];
459459
}
460460
}
461461

@@ -648,7 +648,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
648648
set(uri: vscUri.URI, edits: readonly unknown[]): void {
649649
let data = this._textEdits.get(uri.toString());
650650
if (!data) {
651-
data = { seq: this._seqPool += 1, uri, edits: [] };
651+
data = { seq: (this._seqPool += 1), uri, edits: [] };
652652
this._textEdits.set(uri.toString(), data);
653653
}
654654
if (!edits) {
@@ -884,7 +884,7 @@ export class Diagnostic {
884884

885885
toJSON(): { severity: DiagnosticSeverity; message: string; range: Range; source: string; code: string | number } {
886886
return {
887-
severity: (DiagnosticSeverity[this.severity] as unknown) as DiagnosticSeverity,
887+
severity: DiagnosticSeverity[this.severity] as unknown as DiagnosticSeverity,
888888
message: this.message,
889889
range: this.range,
890890
source: this.source,
@@ -933,7 +933,7 @@ export class DocumentHighlight {
933933
toJSON(): { range: Range; kind: DocumentHighlightKind } {
934934
return {
935935
range: this.range,
936-
kind: (DocumentHighlightKind[this.kind] as unknown) as DocumentHighlightKind,
936+
kind: DocumentHighlightKind[this.kind] as unknown as DocumentHighlightKind,
937937
};
938938
}
939939
}
@@ -1008,7 +1008,7 @@ export class SymbolInformation {
10081008
toJSON(): { name: string; kind: SymbolKind; location: Location; containerName: string } {
10091009
return {
10101010
name: this.name,
1011-
kind: (SymbolKind[this.kind] as unknown) as SymbolKind,
1011+
kind: SymbolKind[this.kind] as unknown as SymbolKind,
10121012
location: this.location,
10131013
containerName: this.containerName,
10141014
};
@@ -1269,7 +1269,7 @@ export class CompletionItem {
12691269
return {
12701270
label: this.label,
12711271
label2: this.label2,
1272-
kind: this.kind && ((CompletionItemKind[this.kind] as unknown) as CompletionItemKind),
1272+
kind: this.kind && (CompletionItemKind[this.kind] as unknown as CompletionItemKind),
12731273
detail: this.detail,
12741274
documentation: this.documentation,
12751275
sortText: this.sortText,
@@ -2000,12 +2000,25 @@ export enum TreeItemCollapsibleState {
20002000
Expanded = 2,
20012001
}
20022002

2003-
export class TreeItem {
2004-
label?: string;
2003+
export interface TreeItemLabel {
2004+
label: string;
20052005

2006-
resourceUri?: vscUri.URI;
2006+
highlights?: [number, number][];
2007+
}
2008+
export type IconPath =
2009+
| vscode.Uri
2010+
| {
2011+
light: vscode.Uri;
2012+
2013+
dark: vscode.Uri;
2014+
}
2015+
| ThemeIcon;
2016+
export class TreeItem {
2017+
label?: string | TreeItemLabel;
2018+
id?: string;
2019+
resourceUri?: vscode.Uri;
20072020

2008-
iconPath?: string | vscUri.URI | { light: string | vscUri.URI; dark: string | vscUri.URI };
2021+
iconPath?: string | IconPath;
20092022

20102023
command?: vscode.Command;
20112024

0 commit comments

Comments
 (0)