diff --git a/src/firestore/collection/collection.ts b/src/firestore/collection/collection.ts index f3498a3ce..94a953577 100644 --- a/src/firestore/collection/collection.ts +++ b/src/firestore/collection/collection.ts @@ -9,7 +9,7 @@ import { AngularFirestoreDocument } from '../document/document'; import { AngularFirestore } from '../firestore'; export function validateEventsArray(events?: DocumentChangeType[]) { - if (!events || events!.length === 0) { + if (!events || events.length === 0) { events = ['added', 'removed', 'modified']; } return events; @@ -98,6 +98,7 @@ export class AngularFirestoreCollection { * provided `idField` property name. */ valueChanges(): Observable; + // tslint:disable-next-line:unified-signatures valueChanges({}): Observable; valueChanges(options: {idField: K}): Observable<(T & { [T in K]: string })[]>; valueChanges(options: {idField?: K} = {}): Observable { @@ -106,7 +107,7 @@ export class AngularFirestoreCollection { map(actions => actions.payload.docs.map(a => { if (options.idField) { return { - ...a.data() as Object, + ...a.data() as {}, ...{ [options.idField]: a.id } } as T & { [T in K]: string }; } else { diff --git a/src/firestore/firestore.ts b/src/firestore/firestore.ts index 069e642b3..6a2b9e468 100644 --- a/src/firestore/firestore.ts +++ b/src/firestore/firestore.ts @@ -110,6 +110,7 @@ export class AngularFirestore { @Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig: string|FirebaseAppConfig|null|undefined, @Optional() @Inject(ENABLE_PERSISTENCE) shouldEnablePersistence: boolean|null, @Optional() @Inject(SETTINGS) settings: Settings|null, + // tslint:disable-next-line:ban-types @Inject(PLATFORM_ID) platformId: Object, zone: NgZone, @Optional() @Inject(PERSISTENCE_SETTINGS) persistenceSettings: PersistenceSettings|null, @@ -149,8 +150,7 @@ export class AngularFirestore { * CollectionReference and an optional query function to narrow the result * set. */ - collection(path: string, queryFn?: QueryFn): AngularFirestoreCollection; - collection(ref: CollectionReference, queryFn?: QueryFn): AngularFirestoreCollection; + collection(path: string| CollectionReference, queryFn?: QueryFn): AngularFirestoreCollection; collection(pathOrRef: string | CollectionReference, queryFn?: QueryFn): AngularFirestoreCollection { let collectionRef: CollectionReference; if (typeof pathOrRef === 'string') { diff --git a/src/remote-config/remote-config.ts b/src/remote-config/remote-config.ts index f1f19183e..0f247d8d2 100644 --- a/src/remote-config/remote-config.ts +++ b/src/remote-config/remote-config.ts @@ -14,6 +14,16 @@ export const DEFAULTS = new InjectionToken('angularfire2.remoteC export interface AngularFireRemoteConfig extends ɵPromiseProxy { } +// TODO look into the types here, I don't like the anys +const proxyAll = (observable: Observable, as: 'numbers' | 'booleans' | 'strings') => new Proxy( + observable.pipe(mapToObject(as as any)), { + get: (self, name: string) => self[name] || observable.pipe( + map(all => all.find(p => p.key === name)), + map(param => param ? param[AS_TO_FN[as]]() : STATIC_VALUES[as]), + distinctUntilChanged() + ) + } +) as any; // TODO export as implements Partial<...> so minor doesn't break us export class Value implements remoteConfig.Value { @@ -266,13 +276,3 @@ export function mapToObject(to: 'numbers' | 'booleans' ); } -// TODO look into the types here, I don't like the anys -const proxyAll = (observable: Observable, as: 'numbers' | 'booleans' | 'strings') => new Proxy( - observable.pipe(mapToObject(as as any)), { - get: (self, name: string) => self[name] || observable.pipe( - map(all => all.find(p => p.key === name)), - map(param => param ? param[AS_TO_FN[as]]() : STATIC_VALUES[as]), - distinctUntilChanged() - ) - } -) as any; diff --git a/src/schematics/deploy/actions.ts b/src/schematics/deploy/actions.ts index 90fd1fa07..1e94d55cc 100644 --- a/src/schematics/deploy/actions.ts +++ b/src/schematics/deploy/actions.ts @@ -9,7 +9,7 @@ import { experimental } from '@angular-devkit/core'; import { SchematicsException } from '@angular-devkit/schematics'; import { satisfies } from 'semver'; -const escapeRegExp = (str: String) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); +const escapeRegExp = (str: string) => str.replace(/[\-\[\]\/{}()*+?.\\^$|]/g, '\\$&'); const moveSync = (src: string, dest: string) => { copySync(src, dest); @@ -30,7 +30,7 @@ const deployToHosting = ( execSync(`open http://localhost:${port} || true`); }, 1500); - return firebaseTools.serve({ port, targets: ['hosting']}).then(() => + return firebaseTools.serve({ port, targets: ['hosting'] }).then(() => require('inquirer').prompt({ type: 'confirm', name: 'deployProject', @@ -78,19 +78,24 @@ const getPackageJson = (context: BuilderContext, workspaceRoot: string) => { const npmList = execSync('npm ls || true').toString(); Object.keys(dependencies).forEach((dependency: string) => { const npmLsMatch = npmList.match(` ${escapeRegExp(dependency)}@.+\\w`); - if (npmLsMatch) { dependencies[dependency] = npmLsMatch[0].split(`${dependency}@`)[1]; } + if (npmLsMatch) { + dependencies[dependency] = npmLsMatch[0].split(`${dependency}@`)[1]; + } }); Object.keys(devDependencies).forEach((devDependency: string) => { const npmLsMatch = npmList.match(` ${escapeRegExp(devDependency)}@.+\\w`); - if (npmLsMatch) { devDependencies[devDependency] = npmLsMatch[0].split(`${devDependency}@`)[1]; } + if (npmLsMatch) { + devDependencies[devDependency] = npmLsMatch[0].split(`${devDependency}@`)[1]; + } }); if (existsSync(join(workspaceRoot, 'angular.json'))) { const angularJson = JSON.parse(readFileSync(join(workspaceRoot, 'angular.json')).toString()); + // tslint:disable-next-line:no-non-null-assertion const server = angularJson.projects[context.target!.project].architect.server; const serverOptions = server && server.options; const externalDependencies = serverOptions && serverOptions.externalDependencies || []; const bundleDependencies = serverOptions && serverOptions.bundleDependencies; - if (bundleDependencies == false) { + if (bundleDependencies !== true) { if (existsSync(join(workspaceRoot, 'package.json'))) { const packageJson = JSON.parse(readFileSync(join(workspaceRoot, 'package.json')).toString()); Object.keys(packageJson.dependencies).forEach((dependency: string) => { @@ -100,7 +105,9 @@ const getPackageJson = (context: BuilderContext, workspaceRoot: string) => { } else { externalDependencies.forEach(externalDependency => { const npmLsMatch = npmList.match(` ${escapeRegExp(externalDependency)}@.+\\w`); - if (npmLsMatch) { dependencies[externalDependency] = npmLsMatch[0].split(`${externalDependency}@`)[1]; } + if (npmLsMatch) { + dependencies[externalDependency] = npmLsMatch[0].split(`${externalDependency}@`)[1]; + } }); } } // TODO should we throw? @@ -177,7 +184,7 @@ export const deployToFunction = async ( execSync(`open http://localhost:${port} || true`); }, 1500); - return firebaseTools.serve({ port, targets: ['hosting', 'functions']}).then(() => + return firebaseTools.serve({ port, targets: ['hosting', 'functions'] }).then(() => require('inquirer').prompt({ type: 'confirm', name: 'deployProject', @@ -186,6 +193,7 @@ export const deployToFunction = async ( ).then(({ deployProject }: { deployProject: boolean }) => { if (deployProject) { return firebaseTools.deploy({ + // tslint:disable-next-line:no-non-null-assertion only: `hosting:${context.target!.project},functions:ssr`, cwd: workspaceRoot }); @@ -195,6 +203,7 @@ export const deployToFunction = async ( }); } else { return firebaseTools.deploy({ + // tslint:disable-next-line:no-non-null-assertion only: `hosting:${context.target!.project},functions:ssr`, cwd: workspaceRoot }); @@ -233,8 +242,6 @@ export default async function deploy( } try { - let success: { hosting: string }; - const winston = require('winston'); const tripleBeam = require('triple-beam'); @@ -243,14 +250,14 @@ export default async function deploy( level: 'info', format: winston.format.printf((info) => [info.message, ...(info[tripleBeam.SPLAT] || [])] - .filter((chunk) => typeof chunk == 'string') + .filter((chunk) => typeof chunk === 'string') .join(' ') - ), + ) }) ); if (ssr) { - success = await deployToFunction( + await deployToFunction( firebaseTools, context, context.workspaceRoot, @@ -258,7 +265,7 @@ export default async function deploy( preview ); } else { - success = await deployToHosting( + await deployToHosting( firebaseTools, context, context.workspaceRoot,