Skip to content

Commit 90e2c67

Browse files
author
Anatoly Ostrovsky
committed
New typecheck settings
1 parent 758aebe commit 90e2c67

File tree

27 files changed

+230
-112
lines changed

27 files changed

+230
-112
lines changed

.husky/pre-commit

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
make lint
2-
make check
32
make types
43
make pretty
54
git add ./

@types/angular.d.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,19 @@ export class Angular {
1212
/**
1313
* Gets the controller instance for a given element, if exists. Defaults to "ngControllerController"
1414
*
15-
* @type {(element: Element, name: string?) => ng.Scope|undefined}
15+
* @type {(element: Element, name?: string) => ng.Scope|undefined}
1616
*/
17-
getController: (
18-
element: Element,
19-
name: string | null,
20-
) => ng.Scope | undefined;
17+
getController: (element: Element, name?: string) => ng.Scope | undefined;
2118
/**
2219
* Return instance of InjectorService attached to element
23-
* @type {(Element) => ng.InjectorService}
20+
* @type {typeof getInjector}
2421
*/
25-
getInjector: (Element: any) => ng.InjectorService;
22+
getInjector: typeof getInjector;
2623
/**
2724
* Gets scope for a given element.
28-
* @type {(Element) => ng.Scope}
25+
* @type {typeof getScope}
2926
*/
30-
getScope: (Element: any) => ng.Scope;
27+
getScope: typeof getScope;
3128
errorHandlingConfig: typeof errorHandlingConfig;
3229
$t: Readonly<Record<string, string>>;
3330
/**
@@ -158,5 +155,10 @@ export class Angular {
158155
*/
159156
getScopeByName(name: string): ProxyHandler<ng.Scope> | undefined;
160157
}
158+
export type ModuleRegistry = {
159+
[x: string]: NgModule;
160+
};
161+
import { getInjector } from "./shared/dom.js";
162+
import { getScope } from "./shared/dom.js";
161163
import { errorHandlingConfig } from "./shared/utils.js";
162164
import { NgModule } from "./core/di/ng-module/ng-module.js";

@types/core/scope/scope.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class Scope {
6262
}
6363
>;
6464
/** Current proxy being operated on */
65-
$proxy: any;
65+
$proxy: ProxyConstructor | ng.Scope;
6666
/** @type {Scope} The actual proxy */
6767
$handler: Scope;
6868
/** @type {*} Current target being called on */

@types/directive/ref/ref.d.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
export function ngRefDirective($parse: any): {
2-
priority: number;
3-
restrict: string;
4-
compile(
5-
tElement: any,
6-
tAttrs: any,
7-
): (scope: any, element: any, attrs: any) => void;
8-
};
1+
/**
2+
* @param {ng.ParseService} $parse
3+
* @return {ng.Directive}
4+
*/
5+
export function ngRefDirective($parse: ng.ParseService): ng.Directive;
96
export namespace ngRefDirective {
107
let $inject: string[];
118
}

@types/interface.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ export type DirectiveLinkFn<T> = (
358358
* A compile function used to prepare directives before linking.
359359
*/
360360
export type DirectiveCompileFn = (
361-
templateElement?: HTMLElement,
362-
templateAttributes?: Attributes & Record<string, any>,
361+
templateElement: HTMLElement,
362+
templateAttributes: Attributes & Record<string, any>,
363363
transclude?: (...args: any[]) => any,
364364
) => void | DirectiveLinkFn<any> | DirectivePrePost;
365365
/**

@types/namespace.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ import { AnimateProvider as TAnimateProvider } from "./animations/animate.js";
9595
import { UrlService as TUrlService } from "./router/url/url-service.js";
9696
import { LocationProvider as TLocationProvider } from "./services/location/location.js";
9797
import { ViewService as TViewService } from "./router/view/view.js";
98+
import { StateDeclaration as TStateDeclaration } from "./router/state/interface.ts";
99+
import { StateObject as TStateObject } from "./router/state/state-object.js";
98100
declare global {
99101
interface Function {
100102
$inject?: readonly string[] | undefined;
@@ -182,5 +184,7 @@ declare global {
182184
type Expression = TExpression;
183185
type NgModelController = TNgModelController;
184186
type Validator = TValidator;
187+
type StateDeclaration = TStateDeclaration;
188+
type StateObject = TStateObject;
185189
}
186190
}

@types/router/state/state-builder.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@
3838
* new Resolvable("myBarResolve", function(dep) { return dep.fetchSomethingAsPromise() }, [ "DependencyName" ]),
3939
* { provide: "myBazResolve", useFactory: function(dep) { dep.fetchSomethingAsPromise() }, deps: [ "DependencyName" ] }
4040
* ]
41+
* @param {ng.StateObject} state
4142
*/
42-
export function resolvablesBuilder(state: any): any[];
43+
export function resolvablesBuilder(state: ng.StateObject): any[];
4344
/**
4445
* A internal global service
4546
*

@types/router/state/state-object.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export class StateObject implements StateDeclaration {
2424
includes: any;
2525
$$state: () => this;
2626
/**
27-
* @type {import('./interface.ts').StateDeclaration}
27+
* @type {ng.StateDeclaration}
2828
*/
29-
self: import("./interface.ts").StateDeclaration;
29+
self: ng.StateDeclaration;
3030
__stateObjectCache: {
3131
nameGlob: Glob;
3232
};

@types/router/state/state-queue-manager.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@ export class StateQueueManager {
22
/**
33
* @param {import("./state-registry.js").StateRegistryProvider} stateRegistry
44
* @param {*} urlServiceRules
5-
* @param {*} states
5+
* @param {Record<string, ng.StateObject>} states
66
* @param {*} builder
77
* @param {*} listeners
88
*/
99
constructor(
1010
stateRegistry: import("./state-registry.js").StateRegistryProvider,
1111
urlServiceRules: any,
12-
states: any,
12+
states: Record<string, ng.StateObject>,
1313
builder: any,
1414
listeners: any,
1515
);
1616
stateRegistry: import("./state-registry.js").StateRegistryProvider;
1717
urlServiceRules: any;
18-
states: any;
18+
states: Record<string, StateObject>;
1919
builder: any;
2020
listeners: any;
2121
/**
2222
* @type {Array<StateObject>}
2323
*/
2424
queue: Array<StateObject>;
2525
register(stateDecl: any): StateObject;
26-
flush(): any;
26+
flush(): Record<string, StateObject>;
2727
attachRoute(state: any): void;
2828
}
2929
import { StateObject } from "./state-object.js";

@types/router/state/state-registry.d.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@
88
export class StateRegistryProvider {
99
static $inject: string[];
1010
/**
11-
* @param urlService
12-
* @param stateService
13-
* @param {import('../router.js').RouterProvider} globals
14-
* @param viewService
11+
* @param {ng.UrlService} urlService
12+
* @param {ng.StateService} stateService
13+
* @param {ng.RouterService} globals
14+
* @param {ng.ViewService} viewService
1515
*/
1616
constructor(
17-
urlService: any,
18-
stateService: any,
19-
globals: import("../router.js").RouterProvider,
20-
viewService: any,
17+
urlService: ng.UrlService,
18+
stateService: ng.StateService,
19+
globals: ng.RouterService,
20+
viewService: ng.ViewService,
2121
);
22-
states: {};
23-
urlService: any;
24-
urlServiceRules: any;
22+
/** @type {Record<string, import("./state-object.js").StateObject>} */
23+
states: Record<string, import("./state-object.js").StateObject>;
24+
urlService: import("../url/url-service.js").UrlService;
25+
urlServiceRules: import("../url/url-rules.js").UrlRules;
2526
$injector: any;
2627
listeners: any[];
2728
matcher: StateMatcher;
@@ -110,6 +111,10 @@ export class StateRegistryProvider {
110111
* @returns {import('./state-object').StateObject[]} a list of removed states
111112
*/
112113
deregister(stateOrName: any): any[];
114+
/**
115+
* @return {ng.StateDeclaration[]}
116+
*/
117+
getAll(): ng.StateDeclaration[];
113118
get(stateOrName: any, base: any, ...args: any[]): any;
114119
/**
115120
* Registers a [[BuilderFunction]] for a specific [[StateObject]] property (e.g., `parent`, `url`, or `path`).

0 commit comments

Comments
 (0)