Re-enable --strict flag in messaging/ (#643)

* Reenable --strict in messaging/

* Revert "Remove some assertions that are no longer needed as --strict is disabled"

This reverts commit 6ea7e54640ea3c19942a1881a3f738d89b51dafe.

* Fix strict issues in messaging/

* Fix type errors in app/

* Fix errors

* Fix errors
This commit is contained in:
Mertcan Mermerkaya
2018-04-07 11:40:34 +01:00
committed by GitHub
parent 2d24a5fe70
commit 9e73645290
10 changed files with 26 additions and 25 deletions
+2 -2
View File
@@ -47,7 +47,7 @@ const DEFAULT_ENTRY_NAME = '[DEFAULT]';
// An array to capture listeners before the true auth functions
// exist
let tokenListeners = [];
let tokenListeners: any[] = [];
/**
* Global context object for a collection of services using
@@ -71,7 +71,7 @@ class FirebaseAppImpl implements FirebaseApp {
config: FirebaseAppConfig,
private firebase_: FirebaseNamespace
) {
this.name_ = config.name;
this.name_ = config.name!;
this._automaticDataCollectionEnabled =
config.automaticDataCollectionEnabled || false;
this.options_ = deepCopy<FirebaseOptions>(options);
@@ -55,7 +55,7 @@ export abstract class ControllerInterface {
throw this.errorFactory_.create(ERROR_CODES.BAD_SENDER_ID);
}
this.messagingSenderId_ = app.options[SENDER_ID_OPTION_NAME];
this.messagingSenderId_ = app.options[SENDER_ID_OPTION_NAME]!;
this.tokenDetailsModel_ = new TokenDetailsModel();
this.vapidDetailsModel_ = new VapidDetailsModel();
@@ -128,7 +128,7 @@ export abstract class ControllerInterface {
);
if (isTokenValid) {
const now = Date.now();
if (now < tokenDetails.createTime + TOKEN_EXPIRATION_MILLIS) {
if (now < tokenDetails.createTime! + TOKEN_EXPIRATION_MILLIS) {
return tokenDetails.fcmToken;
} else {
return this.updateToken(
@@ -367,9 +367,9 @@ function isTokenStillValid(
// subscription.getKey('<key name>').
return (
pushSubscription.endpoint === tokenDetails.endpoint &&
arrayBufferToBase64(pushSubscription.getKey('auth')) ===
arrayBufferToBase64(pushSubscription.getKey('auth')!) ===
tokenDetails.auth &&
arrayBufferToBase64(pushSubscription.getKey('p256dh')) ===
arrayBufferToBase64(pushSubscription.getKey('p256dh')!) ===
tokenDetails.p256dh
);
}
@@ -92,7 +92,7 @@ export class WindowController extends ControllerInterface
return this.manifestCheckPromise_;
}
const manifestTag: HTMLAnchorElement = document.querySelector(
const manifestTag = document.querySelector<HTMLAnchorElement>(
'link[rel="manifest"]'
);
if (!manifestTag) {
+4 -4
View File
@@ -46,8 +46,8 @@ export class IIDModel {
subscription: PushSubscription,
publicVapidKey: Uint8Array
): Promise<IIDDetails> {
const p256dh = arrayBufferToBase64(subscription.getKey('p256dh'));
const auth = arrayBufferToBase64(subscription.getKey('auth'));
const p256dh = arrayBufferToBase64(subscription.getKey('p256dh')!);
const auth = arrayBufferToBase64(subscription.getKey('auth')!);
let fcmSubscribeBody =
`authorized_entity=${senderId}&` +
@@ -112,8 +112,8 @@ export class IIDModel {
subscription: PushSubscription,
publicVapidKey: Uint8Array
): Promise<string> {
const p256dh = arrayBufferToBase64(subscription.getKey('p256dh'));
const auth = arrayBufferToBase64(subscription.getKey('auth'));
const p256dh = arrayBufferToBase64(subscription.getKey('p256dh')!);
const auth = arrayBufferToBase64(subscription.getKey('auth')!);
let fcmUpdateBody =
`push_set=${fcmPushSet}&` +
@@ -171,8 +171,8 @@ export class TokenDetailsModel extends DBInterface {
swScope: tokenDetails.swScope,
vapidKey: arrayBufferToBase64(tokenDetails.vapidKey as Uint8Array),
endpoint: tokenDetails.subscription.endpoint,
auth: arrayBufferToBase64(tokenDetails.subscription.getKey('auth')),
p256dh: arrayBufferToBase64(tokenDetails.subscription.getKey('p256dh')),
auth: arrayBufferToBase64(tokenDetails.subscription.getKey('auth')!),
p256dh: arrayBufferToBase64(tokenDetails.subscription.getKey('p256dh')!),
fcmSenderId: tokenDetails.fcmSenderId,
fcmToken: tokenDetails.fcmToken,
fcmPushSet: tokenDetails.fcmPushSet,
@@ -51,8 +51,8 @@ describe('Firebase Messaging > *Controller.getToken()', () => {
swScope: '/example-scope',
vapidKey: DEFAULT_VAPID_KEY,
endpoint: FAKE_SUBSCRIPTION.endpoint,
auth: arrayBufferToBase64(FAKE_SUBSCRIPTION['getKey']('auth')),
p256dh: arrayBufferToBase64(FAKE_SUBSCRIPTION['getKey']('p256dh')),
auth: arrayBufferToBase64(FAKE_SUBSCRIPTION['getKey']('auth')!),
p256dh: arrayBufferToBase64(FAKE_SUBSCRIPTION['getKey']('p256dh')!),
fcmSenderId: EXAMPLE_SENDER_ID,
fcmToken: 'qwerty1',
fcmPushSet: '87654321',
@@ -62,8 +62,8 @@ describe('Firebase Messaging > *Controller.getToken()', () => {
swScope: '/example-scope',
vapidKey: CUSTOM_VAPID_KEY,
endpoint: FAKE_SUBSCRIPTION.endpoint,
auth: arrayBufferToBase64(FAKE_SUBSCRIPTION['getKey']('auth')),
p256dh: arrayBufferToBase64(FAKE_SUBSCRIPTION['getKey']('p256dh')),
auth: arrayBufferToBase64(FAKE_SUBSCRIPTION['getKey']('auth')!),
p256dh: arrayBufferToBase64(FAKE_SUBSCRIPTION['getKey']('p256dh')!),
fcmSenderId: EXAMPLE_SENDER_ID,
fcmToken: 'qwerty2',
fcmPushSet: '7654321',
@@ -73,8 +73,8 @@ describe('Firebase Messaging > *Controller.getToken()', () => {
swScope: '/example-scope',
vapidKey: DEFAULT_VAPID_KEY,
endpoint: FAKE_SUBSCRIPTION.endpoint,
auth: arrayBufferToBase64(FAKE_SUBSCRIPTION['getKey']('auth')),
p256dh: arrayBufferToBase64(FAKE_SUBSCRIPTION['getKey']('p256dh')),
auth: arrayBufferToBase64(FAKE_SUBSCRIPTION['getKey']('auth')!),
p256dh: arrayBufferToBase64(FAKE_SUBSCRIPTION['getKey']('p256dh')!),
fcmSenderId: EXAMPLE_SENDER_ID,
fcmToken: 'qwerty3',
fcmPushSet: '654321',
+1 -1
View File
@@ -28,7 +28,7 @@ export function makeFakeSWReg(
sinon.stub(fakeReg, 'scope').value('/injected-scope');
const states = ['installing', 'waiting', 'active'];
states.forEach(state => {
let finalValue = undefined;
let finalValue: object | undefined = undefined;
if (state === selectedState) {
finalValue = desiredValue;
}
@@ -36,8 +36,8 @@ export function compareDetails(
const subscriptionKeys = ['endpoint', 'auth', 'p256dh'];
const subscriptionValues = {
endpoint: input.subscription.endpoint,
auth: arrayBufferToBase64(input.subscription.getKey('auth')),
p256dh: arrayBufferToBase64(input.subscription.getKey('p256dh'))
auth: arrayBufferToBase64(input.subscription.getKey('auth')!),
p256dh: arrayBufferToBase64(input.subscription.getKey('p256dh')!)
};
subscriptionKeys.forEach(keyName => {
@@ -92,7 +92,7 @@ describe('Firebase Messaging > TokenDetailsModel.getTokenDetailsFromToken()', ()
})
.then(details => {
assert.exists(details);
compareDetails(EXAMPLE_INPUT, details, now);
compareDetails(EXAMPLE_INPUT, details!, now);
clock.restore();
});
});
@@ -114,7 +114,7 @@ describe('Firebase Messaging > TokenDetailsModel.getTokenDetailsFromToken()', ()
})
.then(details => {
assert.exists(details);
compareDetails(EXAMPLE_INPUT, details, now);
compareDetails(EXAMPLE_INPUT, details!, now);
clock.restore();
});
});
+2 -1
View File
@@ -1,7 +1,8 @@
{
"extends": "../../config/tsconfig.base.json",
"compilerOptions": {
"outDir": "dist"
"outDir": "dist",
"strict": true
},
"exclude": [
"dist/**/*"