angular-cn/tools/public_api_guard/platform-browser/platform-browser.d.ts

133 lines
3.9 KiB
TypeScript
Raw Normal View History

export declare class BrowserModule {
constructor(parentModule: BrowserModule | null);
static withServerTransition(params: {
appId: string;
}): ModuleWithProviders<BrowserModule>;
}
export declare class BrowserTransferStateModule {
}
export declare class By {
static all(): Predicate<DebugElement>;
static css(selector: string): Predicate<DebugElement>;
static directive(type: Type<any>): Predicate<DebugElement>;
}
export declare function disableDebugTools(): void;
/** @deprecated */
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 DOCUMENT: InjectionToken<Document>;
export declare abstract class DomSanitizer implements Sanitizer {
abstract bypassSecurityTrustHtml(value: string): SafeHtml;
abstract bypassSecurityTrustResourceUrl(value: string): SafeResourceUrl;
abstract bypassSecurityTrustScript(value: string): SafeScript;
abstract bypassSecurityTrustStyle(value: string): SafeStyle;
abstract bypassSecurityTrustUrl(value: string): SafeUrl;
abstract sanitize(context: SecurityContext, value: SafeValue | string | null): string | null;
}
export declare function enableDebugTools<T>(ref: ComponentRef<T>): ComponentRef<T>;
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 EVENT_MANAGER_PLUGINS: InjectionToken<EventManagerPlugin[]>;
export declare class EventManager {
constructor(plugins: EventManagerPlugin[], _zone: NgZone);
addEventListener(element: HTMLElement, eventName: string, handler: Function): Function;
addGlobalEventListener(target: string, eventName: string, handler: Function): Function;
getZone(): NgZone;
}
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 HAMMER_GESTURE_CONFIG: InjectionToken<HammerGestureConfig>;
export declare const HAMMER_LOADER: InjectionToken<HammerLoader>;
export declare class HammerGestureConfig {
events: string[];
options?: {
cssProps?: any;
domEvents?: boolean;
enable?: boolean | ((manager: any) => boolean);
preset?: any[];
touchAction?: string;
recognizers?: any[];
inputClass?: any;
inputTarget?: EventTarget;
};
overrides: {
[key: string]: Object;
};
buildHammer(element: HTMLElement): HammerInstance;
}
export declare type HammerLoader = () => Promise<void>;
export declare function makeStateKey<T = void>(key: string): StateKey<T>;
export declare class Meta {
constructor(_doc: any);
addTag(tag: MetaDefinition, forceCreation?: boolean): HTMLMetaElement | null;
addTags(tags: MetaDefinition[], forceCreation?: boolean): HTMLMetaElement[];
getTag(attrSelector: string): HTMLMetaElement | null;
getTags(attrSelector: string): HTMLMetaElement[];
removeTag(attrSelector: string): void;
removeTagElement(meta: HTMLMetaElement): void;
updateTag(tag: MetaDefinition, selector?: string): HTMLMetaElement | null;
}
export declare type MetaDefinition = {
charset?: string;
content?: string;
httpEquiv?: string;
id?: string;
itemprop?: string;
name?: string;
property?: string;
scheme?: string;
url?: string;
} & {
[prop: string]: string;
};
export declare const platformBrowser: (extraProviders?: StaticProvider[]) => PlatformRef;
export interface SafeHtml extends SafeValue {
}
export interface SafeResourceUrl extends SafeValue {
}
export interface SafeScript extends SafeValue {
}
export interface SafeStyle extends SafeValue {
}
export interface SafeUrl extends SafeValue {
}
export interface SafeValue {
}
export declare type StateKey<T> = string & {
__not_a_string: never;
};
export declare class Title {
constructor(_doc: any);
getTitle(): string;
setTitle(newTitle: string): void;
}
export declare class TransferState {
get<T>(key: StateKey<T>, defaultValue: T): T;
hasKey<T>(key: StateKey<T>): boolean;
onSerialize<T>(key: StateKey<T>, callback: () => T): void;
remove<T>(key: StateKey<T>): void;
set<T>(key: StateKey<T>, value: T): void;
toJson(): string;
}
export declare const VERSION: Version;