angular-cn/tools/public_api_guard/common/index.d.ts

270 lines
8.1 KiB
TypeScript
Raw Normal View History

/** @stable */
feat(core): Add type information to injector.get() (#13785) - Introduce `InjectionToken<T>` which is a parameterized and type-safe version of `OpaqueToken`. DEPRECATION: - `OpaqueToken` is now deprecated, use `InjectionToken<T>` instead. - `Injector.get(token: any, notFoundValue?: any): any` is now deprecated use the same method which is now overloaded as `Injector.get<T>(token: Type<T>|InjectionToken<T>, notFoundValue?: T): T;`. Migration - Replace `OpaqueToken` with `InjectionToken<?>` and parameterize it. - Migrate your code to only use `Type<?>` or `InjectionToken<?>` as injection tokens. Using other tokens will not be supported in the future. BREAKING CHANGE: - Because `injector.get()` is now parameterize it is possible that code which used to work no longer type checks. Example would be if one injects `Foo` but configures it as `{provide: Foo, useClass: MockFoo}`. The injection instance will be that of `MockFoo` but the type will be `Foo` instead of `any` as in the past. This means that it was possible to call a method on `MockFoo` in the past which now will fail type check. See this example: ``` class Foo {} class MockFoo extends Foo { setupMock(); } var PROVIDERS = [ {provide: Foo, useClass: MockFoo} ]; ... function myTest(injector: Injector) { var foo = injector.get(Foo); // This line used to work since `foo` used to be `any` before this // change, it will now be `Foo`, and `Foo` does not have `setUpMock()`. // The fix is to downcast: `injector.get(Foo) as MockFoo`. foo.setUpMock(); } ``` PR Close #13785
2017-01-03 19:54:46 -05:00
export declare const APP_BASE_HREF: InjectionToken<string>;
/** @stable */
export declare class AsyncPipe implements OnDestroy, PipeTransform {
constructor(_ref: ChangeDetectorRef);
ngOnDestroy(): void;
transform(obj: Observable<any> | Promise<any> | EventEmitter<any>): any;
}
/** @stable */
export declare class CommonModule {
}
/** @stable */
export declare class CurrencyPipe implements PipeTransform {
constructor(_locale: string);
transform(value: any, currencyCode?: string, symbolDisplay?: boolean, digits?: string): string;
}
/** @stable */
export declare class DatePipe implements PipeTransform {
constructor(_locale: string);
transform(value: any, pattern?: string): string;
}
/** @stable */
export declare class DecimalPipe implements PipeTransform {
constructor(_locale: string);
transform(value: any, digits?: string): string;
}
/** @stable */
export declare class HashLocationStrategy extends LocationStrategy {
constructor(_platformLocation: PlatformLocation, _baseHref?: string);
back(): void;
forward(): void;
getBaseHref(): string;
onPopState(fn: LocationChangeListener): void;
path(includeHash?: boolean): string;
prepareExternalUrl(internal: string): string;
pushState(state: any, title: string, path: string, queryParams: string): void;
replaceState(state: any, title: string, path: string, queryParams: string): void;
}
/** @experimental */
export declare class I18nPluralPipe implements PipeTransform {
constructor(_localization: NgLocalization);
transform(value: number, pluralMap: {
[count: string]: string;
}): string;
}
/** @experimental */
export declare class I18nSelectPipe implements PipeTransform {
transform(value: string, mapping: {
[key: string]: string;
}): string;
}
/** @stable */
export declare class JsonPipe implements PipeTransform {
transform(value: any): string;
}
/** @stable */
export declare class Location {
constructor(platformStrategy: LocationStrategy);
back(): void;
forward(): void;
go(path: string, query?: string): void;
isCurrentPathEqualTo(path: string, query?: string): boolean;
normalize(url: string): string;
path(includeHash?: boolean): string;
prepareExternalUrl(url: string): string;
replaceState(path: string, query?: string): void;
subscribe(onNext: (value: PopStateEvent) => void, onThrow?: (exception: any) => void, onReturn?: () => void): Object;
static joinWithSlash(start: string, end: string): string;
static normalizeQueryParams(params: string): string;
static stripTrailingSlash(url: string): string;
}
/** @experimental */
export interface LocationChangeEvent {
type: string;
}
/** @experimental */
export interface LocationChangeListener {
(e: LocationChangeEvent): any;
}
/** @stable */
export declare abstract class LocationStrategy {
abstract back(): void;
abstract forward(): void;
abstract getBaseHref(): string;
abstract onPopState(fn: LocationChangeListener): void;
abstract path(includeHash?: boolean): string;
abstract prepareExternalUrl(internal: string): string;
abstract pushState(state: any, title: string, url: string, queryParams: string): void;
abstract replaceState(state: any, title: string, url: string, queryParams: string): void;
}
/** @stable */
export declare class LowerCasePipe implements PipeTransform {
transform(value: string): string;
}
/** @stable */
export declare class NgClass implements DoCheck {
klass: string;
2016-07-07 19:35:13 -04:00
ngClass: string | string[] | Set<string> | {
[klass: string]: any;
};
constructor(_iterableDiffers: IterableDiffers, _keyValueDiffers: KeyValueDiffers, _ngEl: ElementRef, _renderer: Renderer);
ngDoCheck(): void;
}
/** @experimental */
export declare class NgComponentOutlet implements OnChanges, OnDestroy {
ngComponentOutlet: Type<any>;
ngComponentOutletContent: any[][];
ngComponentOutletInjector: Injector;
ngComponentOutletNgModuleFactory: NgModuleFactory<any>;
constructor(_viewContainerRef: ViewContainerRef);
ngOnChanges(changes: SimpleChanges): void;
ngOnDestroy(): void;
}
/** @deprecated */
export declare class NgFor extends NgForOf<any> {
}
/** @stable */
export declare class NgForOf<T> implements DoCheck, OnChanges {
ngForOf: NgIterable<T>;
ngForTemplate: TemplateRef<NgForOfRow<T>>;
ngForTrackBy: TrackByFunction<T>;
constructor(_viewContainer: ViewContainerRef, _template: TemplateRef<NgForOfRow<T>>, _differs: IterableDiffers);
ngDoCheck(): void;
2016-07-16 13:35:31 -04:00
ngOnChanges(changes: SimpleChanges): void;
}
/** @stable */
export declare class NgIf {
ngIf: any;
ngIfElse: TemplateRef<NgIfContext>;
ngIfThen: TemplateRef<NgIfContext>;
constructor(_viewContainer: ViewContainerRef, templateRef: TemplateRef<NgIfContext>);
}
/** @experimental */
export declare class NgLocaleLocalization extends NgLocalization {
protected locale: string;
constructor(locale: string);
getPluralCategory(value: any): string;
}
/** @experimental */
export declare abstract class NgLocalization {
abstract getPluralCategory(value: any): string;
}
/** @experimental */
export declare class NgPlural {
ngPlural: number;
constructor(_localization: NgLocalization);
addCase(value: string, switchView: SwitchView): void;
}
/** @experimental */
export declare class NgPluralCase {
value: string;
constructor(value: string, template: TemplateRef<Object>, viewContainer: ViewContainerRef, ngPlural: NgPlural);
}
/** @stable */
export declare class NgStyle implements DoCheck {
2016-07-07 19:35:13 -04:00
ngStyle: {
[key: string]: string;
};
constructor(_differs: KeyValueDiffers, _ngEl: ElementRef, _renderer: Renderer);
ngDoCheck(): void;
}
/** @stable */
export declare class NgSwitch {
ngSwitch: any;
}
/** @stable */
export declare class NgSwitchCase implements DoCheck {
ngSwitchCase: any;
constructor(viewContainer: ViewContainerRef, templateRef: TemplateRef<Object>, ngSwitch: NgSwitch);
ngDoCheck(): void;
}
/** @stable */
export declare class NgSwitchDefault {
constructor(viewContainer: ViewContainerRef, templateRef: TemplateRef<Object>, ngSwitch: NgSwitch);
}
/** @experimental */
export declare class NgTemplateOutlet implements OnChanges {
/** @deprecated */ ngOutletContext: Object;
ngTemplateOutlet: TemplateRef<any>;
ngTemplateOutletContext: Object;
constructor(_viewContainerRef: ViewContainerRef);
ngOnChanges(changes: SimpleChanges): void;
}
/** @stable */
export declare class PathLocationStrategy extends LocationStrategy {
constructor(_platformLocation: PlatformLocation, href?: string);
back(): void;
forward(): void;
getBaseHref(): string;
onPopState(fn: LocationChangeListener): void;
path(includeHash?: boolean): string;
prepareExternalUrl(internal: string): string;
pushState(state: any, title: string, url: string, queryParams: string): void;
replaceState(state: any, title: string, url: string, queryParams: string): void;
}
/** @stable */
export declare class PercentPipe implements PipeTransform {
constructor(_locale: string);
transform(value: any, digits?: string): string;
}
/** @stable */
export declare abstract class PlatformLocation {
readonly hash: string;
readonly pathname: string;
readonly search: string;
abstract back(): void;
abstract forward(): void;
abstract getBaseHrefFromDOM(): string;
abstract onHashChange(fn: LocationChangeListener): void;
abstract onPopState(fn: LocationChangeListener): void;
abstract pushState(state: any, title: string, url: string): void;
abstract replaceState(state: any, title: string, url: string): void;
}
/** @experimental */
export interface PopStateEvent {
pop?: boolean;
type?: string;
url?: string;
}
/** @stable */
export declare class SlicePipe implements PipeTransform {
transform(value: any, start: number, end?: number): any;
}
/** @stable */
export declare class TitleCasePipe implements PipeTransform {
transform(value: string): string;
}
/** @stable */
export declare class UpperCasePipe implements PipeTransform {
transform(value: string): string;
}
/** @stable */
export declare const VERSION: Version;