Skip to content

Commit d58ff9b

Browse files
author
Anatoly Ostrovsky
committed
Type improvements
1 parent 80d730d commit d58ff9b

19 files changed

Lines changed: 136 additions & 114 deletions

File tree

@types/core/compile/compile.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class CompileProvider {
2626
/**
2727
* @param {string|Object} name Name of the component in camelCase (i.e. `myComp` which will match `<my-comp>`),
2828
* or an object map of components where the keys are the names and the values are the component definition objects.
29-
* @param {import("../../interface.js").ComponentOptions} options Component definition object (a simplified
29+
* @param {import("../../interface.js").Component} options Component definition object (a simplified
3030
* {directive definition object}),
3131
* with the following properties (all optional):
3232
*
@@ -69,7 +69,7 @@ export class CompileProvider {
6969
*/
7070
component: (
7171
name: string | any,
72-
options: import("../../interface.js").ComponentOptions,
72+
options: import("../../interface.js").Component,
7373
) => CompileProvider;
7474
/**
7575
* Retrieves or overrides the default regular expression that is used for determining trusted safe

@types/core/di/ng-module.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ export class NgModule {
7474
run(block: import("../../interface.ts").Injectable<any>): NgModule;
7575
/**
7676
* @param {string} name
77-
* @param {import("../../interface.ts").ComponentOptions} options
77+
* @param {import("../../interface.ts").Component} options
7878
* @returns {NgModule}
7979
*/
8080
component(
8181
name: string,
82-
options: import("../../interface.ts").ComponentOptions,
82+
options: import("../../interface.ts").Component,
8383
): NgModule;
8484
/**
8585
* @param {string} name

@types/directive/http/http.d.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,35 @@ export function getEventNameForElement(element: Element): EventType;
1212
* Handles DOM manipulation based on a swap strategy and server-rendered HTML.
1313
*
1414
* @param {string} html - The HTML string returned from the server.
15-
* @param {import("../../interface.ts").SwapModeType} swap
15+
* @param {import("./interface.ts").SwapModeType} swap
1616
* @param {Element} target - The target DOM element to apply the swap to.
17-
* @param {import('../../core/scope/scope.js').Scope} scope
18-
* @param {import('../../core/compile/compile.js').CompileFn} $compile
17+
* @param {ng.Scope} scope
18+
* @param {ng.CompileService} $compile
1919
*/
2020
export function handleSwapResponse(
2121
html: string,
22-
swap: import("../../interface.ts").SwapModeType,
22+
swap: import("./interface.ts").SwapModeType,
2323
target: Element,
24-
scope: import("../../core/scope/scope.js").Scope,
25-
$compile: import("../../core/compile/compile.js").CompileFn,
24+
scope: ng.Scope,
25+
$compile: ng.CompileService,
2626
): void;
2727
/**
2828
* Creates an HTTP directive factory that supports GET, DELETE, POST, PUT.
2929
*
3030
* @param {"get" | "delete" | "post" | "put"} method - HTTP method to use.
3131
* @param {string} attrName - Attribute name containing the URL.
32-
* @returns {import('../../interface.ts').DirectiveFactory}
32+
* @returns {ng.DirectiveFactory}
3333
*/
3434
export function createHttpDirective(
3535
method: "get" | "delete" | "post" | "put",
3636
attrName: string,
37-
): import("../../interface.ts").DirectiveFactory;
38-
/** @type {import('../../interface.ts').DirectiveFactory} */
39-
export const ngGetDirective: import("../../interface.ts").DirectiveFactory;
40-
/** @type {import('../../interface.ts').DirectiveFactory} */
41-
export const ngDeleteDirective: import("../../interface.ts").DirectiveFactory;
42-
/** @type {import('../../interface.ts').DirectiveFactory} */
43-
export const ngPostDirective: import("../../interface.ts").DirectiveFactory;
44-
/** @type {import('../../interface.ts').DirectiveFactory} */
45-
export const ngPutDirective: import("../../interface.ts").DirectiveFactory;
37+
): ng.DirectiveFactory;
38+
/** @type {ng.DirectiveFactory} */
39+
export const ngGetDirective: ng.DirectiveFactory;
40+
/** @type {ng.DirectiveFactory} */
41+
export const ngDeleteDirective: ng.DirectiveFactory;
42+
/** @type {ng.DirectiveFactory} */
43+
export const ngPostDirective: ng.DirectiveFactory;
44+
/** @type {ng.DirectiveFactory} */
45+
export const ngPutDirective: ng.DirectiveFactory;
4646
export type EventType = "click" | "change" | "submit";
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Possible values for `data-swap` attribute
3+
*/
4+
export declare const SwapMode: {
5+
/** (default) Replaces the contents inside the element */
6+
readonly innerHTML: "innerHTML";
7+
/** Replaces the entire element, including the tag itself */
8+
readonly outerHTML: "outerHTML";
9+
/** Inserts plain text (without parsing HTML) */
10+
readonly textContent: "textContent";
11+
/** Inserts HTML immediately before the element itself */
12+
readonly beforebegin: "beforebegin";
13+
/** Inserts HTML inside the element, before its first child */
14+
readonly afterbegin: "afterbegin";
15+
/** Inserts HTML inside the element, after its last child */
16+
readonly beforeend: "beforeend";
17+
/** Inserts HTML immediately after the element itself */
18+
readonly afterend: "afterend";
19+
/** Removes the element entirely */
20+
readonly delete: "delete";
21+
/** Performs no insertion (no-op) */
22+
readonly none: "none";
23+
};
24+
/**
25+
* Union type representing all possible DOM insertion modes.
26+
*/
27+
export type SwapModeType = keyof typeof SwapMode;

@types/index.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,24 @@ import { FilterFactory, FilterFn as TFilterFn } from "./filters/interface.ts";
3232
import { InterpolateService as TInterpolateService } from "./core/interpolate/interface.ts";
3333
import { InterpolateProvider } from "./core/interpolate/interpolate.js";
3434
import { SceDelegateProvider, SceProvider } from "./services/sce/sce.js";
35+
import {
36+
Directive as TDirective,
37+
DirectiveFactory as TDirectiveFactory,
38+
Component as TComponent,
39+
Controller as TController,
40+
} from "./interface.ts";
41+
import { StateProvider } from "./router/state/state-service.js";
3542
declare global {
3643
interface Function {
3744
$inject?: readonly string[] | undefined;
3845
}
3946
namespace ng {
4047
type Angular = InstanceType<typeof Angular>;
4148
type Attributes = InstanceType<typeof Attributes>;
49+
type Directive = TDirective;
50+
type DirectiveFactory = TDirectiveFactory;
51+
type Component = TComponent;
52+
type Controller = TController;
4253
type Scope = InstanceType<typeof Scope>;
4354
type NgModule = InstanceType<typeof NgModule>;
4455
type PubSubProvider = InstanceType<typeof PubSubProvider>;
@@ -64,6 +75,7 @@ declare global {
6475
type PubSubService = InstanceType<typeof PubSub>;
6576
type RootElementService = Element;
6677
type RootScopeService = InstanceType<typeof Scope>;
78+
type StateService = InstanceType<typeof StateProvider>;
6779
type TemplateCacheService = InstanceType<typeof Map<string, string>>;
6880
type TemplateRequestService = TTemplateRequestService;
6981
type ErrorHandlingConfig = TErrorHandlingConfig;

@types/interface.d.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export interface Controller {
176176
/**
177177
* Defines a component's configuration object (a simplified directive definition object).
178178
*/
179-
export interface ComponentOptions {
179+
export interface Component {
180180
controller?: string | Injectable<ControllerConstructor> | undefined;
181181
/**
182182
* An identifier name for a reference to the controller. If present, the controller will be published to its scope under
@@ -392,33 +392,6 @@ export interface NgModelController {
392392
/** Current value shown in the view */
393393
$viewValue: any;
394394
}
395-
/**
396-
* Possible values for `data-swap` attribute
397-
*/
398-
export declare const SwapMode: {
399-
/** (default) Replaces the contents inside the element */
400-
readonly innerHTML: "innerHTML";
401-
/** Replaces the entire element, including the tag itself */
402-
readonly outerHTML: "outerHTML";
403-
/** Inserts plain text (without parsing HTML) */
404-
readonly textContent: "textContent";
405-
/** Inserts HTML immediately before the element itself */
406-
readonly beforebegin: "beforebegin";
407-
/** Inserts HTML inside the element, before its first child */
408-
readonly afterbegin: "afterbegin";
409-
/** Inserts HTML inside the element, after its last child */
410-
readonly beforeend: "beforeend";
411-
/** Inserts HTML immediately after the element itself */
412-
readonly afterend: "afterend";
413-
/** Removes the element entirely */
414-
readonly delete: "delete";
415-
/** Performs no insertion (no-op) */
416-
readonly none: "none";
417-
};
418-
/**
419-
* Union type representing all possible DOM insertion modes.
420-
*/
421-
export type SwapModeType = keyof typeof SwapMode;
422395
export interface RootElementService extends Element {}
423396
/**
424397
* The minimal local definitions required by $controller(ctrl, locals) calls.

docs/static/typedoc/assets/navigation.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)