mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* Add typings for tabris-plugin-firebase
tabris-plugin-firebase is a plugin for the framework for mobile app
development Tabris.js [1]. The plugin is made available by the Cordova
ecosystem and can thus only be consumed through a global variable.
Disable linter rule "strict-export-declare-modifiers" since using
"export {};" is the recommended way of exporting nothing when the module
is only to be used through a global variable [2].
Include missing Tabris.js interfaces due to the lack of support for the
"peerDependencies" field in package.json. Remove trivial types, i.e.
the interfaces NativeObjectEvents and NativeObjectProperties which were
essentially of type object. Linter rules disallow empty interfaces.
[1]: https://tabrisjs.com
[2]: https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html
Change-Id: I85a17308ec60647a547981708602089a3da39b07
* Change {} types to object
Those changed types may have own object properties.
Change-Id: I46b68ab018db86ad8d65c43d6dc28ca14e144d0b
68 lines
2.3 KiB
TypeScript
68 lines
2.3 KiB
TypeScript
function testAnalytics() {
|
|
// Properties
|
|
let analyticsCollectionEnabled: boolean;
|
|
let screenName: string;
|
|
let userId: string;
|
|
|
|
analyticsCollectionEnabled = firebase.Analytics.analyticsCollectionEnabled;
|
|
screenName = firebase.Analytics.screenName;
|
|
userId = firebase.Analytics.userId;
|
|
|
|
firebase.Analytics.analyticsCollectionEnabled = analyticsCollectionEnabled;
|
|
firebase.Analytics.screenName = screenName;
|
|
firebase.Analytics.userId = userId;
|
|
|
|
const properties: firebase.AnalyticsProperties = {analyticsCollectionEnabled, screenName, userId};
|
|
const partialProperties: firebase.AnalyticsProperties = {};
|
|
firebase.Analytics.set(properties);
|
|
firebase.Analytics.set(partialProperties);
|
|
|
|
// Methods
|
|
let thisReturnValue: firebase.Analytics;
|
|
const name = '';
|
|
const property = '';
|
|
|
|
thisReturnValue = firebase.Analytics.set({analyticsCollectionEnabled, screenName, userId});
|
|
firebase.Analytics.logEvent(name, {foo: property});
|
|
firebase.Analytics.logEvent(name);
|
|
firebase.Analytics.setUserProperty(name, property);
|
|
}
|
|
|
|
function testMessaging() {
|
|
// Properties
|
|
let instanceId: string;
|
|
let token: string;
|
|
let launchData: object;
|
|
|
|
instanceId = firebase.Messaging.instanceId;
|
|
token = firebase.Messaging.token;
|
|
launchData = firebase.Messaging.launchData;
|
|
|
|
// Methods
|
|
firebase.Messaging.resetInstanceId();
|
|
|
|
// Events
|
|
const target: firebase.Messaging = firebase.Messaging;
|
|
const timeStamp = 0;
|
|
const type = 'foo';
|
|
const value = 'bar';
|
|
const data: any = {};
|
|
|
|
const instanceIdChangedEvent: PropertyChangedEvent<firebase.Messaging, string> = {target, timeStamp, type, value};
|
|
const tokenChangedEvent: PropertyChangedEvent<firebase.Messaging, string> = {target, timeStamp, type, value};
|
|
const messageEvent: firebase.MessageEvent = {target, timeStamp, type, data};
|
|
|
|
firebase.Messaging.on({
|
|
instanceIdChanged: (event: PropertyChangedEvent<firebase.Messaging, string>) => {},
|
|
tokenChanged: (event: PropertyChangedEvent<firebase.Messaging, string>) => {},
|
|
message: (event: firebase.MessageEvent) => {}
|
|
});
|
|
}
|
|
|
|
interface PropertyChangedEvent<T, U> {
|
|
readonly target: T;
|
|
readonly timeStamp: number;
|
|
readonly type: string;
|
|
readonly value: U;
|
|
}
|