Skip to content

Turn tsconfig settings to 11 #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ dist

source/*ngfactory.ts
source/*ngsummary.json

*.tgz
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ coverage/
.vscode/
docs/
webpack/
*.tgz
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@angular-redux/form",
"version": "6.5.1",
"version": "6.5.2",
"description": "Build Angular 2+ forms with Redux",
"dependencies": {
"immutable": "^3.8.1"
Expand Down Expand Up @@ -42,7 +42,7 @@
"reflect-metadata": "^0.1.3",
"rimraf": "^2.5.4",
"rxjs": "^5.0.1",
"typescript": "^2.1.0",
"typescript": "^2.4.1",
"webpack": "^2.1.0-beta.25",
"zone.js": "^0.8.4"
},
Expand Down
30 changes: 3 additions & 27 deletions source/compose-reducers.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
import {Reducer, Action} from 'redux';

import {State} from './state';

export const composeReducers =
<State>(...reducers: Reducer<State>[]): Reducer<State> => {
// Pull from each reducer its initial state value, from the default
// value of the `state' argument. So we are provided with {initialState},
// and then with the individual initial states of each reducer. We
// compose all these states together to produce a true 'initial state'
// for our composed reducer.
let state: State = null;

for (const reducer of reducers) {
const result = reducer.apply(null, [undefined, {type: ''}]);
if (result === undefined) {
continue;
}

if (state == null) {
state = result;
}
else {
state = State.inspect(state).merge(null, result);
}
}

return (s: State = state, action: Action) =>
reducers.reduce((st, reducer) => reducer(st, action), s);
};
<State>(...reducers: Reducer<State>[]): Reducer<State> =>
(s: State, action: Action) =>
reducers.reduce((st, reducer) => reducer(st, action), s);
20 changes: 10 additions & 10 deletions source/connect-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ import {controlPath, selectValueAccessor} from './shims';

export class ConnectArrayTemplate {
constructor(
public $implicit,
public $implicit: any,
public index: number,
public item
public item: any
) {}
}

Expand Down Expand Up @@ -85,7 +85,7 @@ export class ConnectArray extends ControlContainer implements OnInit {
}

@Input()
set connectArrayOf(collection) {
set connectArrayOf(collection: any) {
this.key = collection;

this.resetState(this.store.getState());
Expand Down Expand Up @@ -131,7 +131,7 @@ export class ConnectArray extends ControlContainer implements OnInit {
this.formDirective.form.removeControl(this.key);
}

private resetState(state) {
private resetState(state: any) {
if (this.key == null || this.key.length === 0) {
return; // no state to retreive if no key is set
}
Expand Down Expand Up @@ -174,7 +174,7 @@ export class ConnectArray extends ControlContainer implements OnInit {
}
}

private registerInternals(array) {
private registerInternals(array: any) {
array.registerControl = () => {};
array.registerOnChange = () => {};

Expand All @@ -188,7 +188,7 @@ export class ConnectArray extends ControlContainer implements OnInit {
});
}

private patchDescendantControls(viewRef) {
private patchDescendantControls(viewRef: any) {
const groups = Object.keys(viewRef._view)
.map(k => viewRef._view[k])
.filter(c => c instanceof NgModelGroup);
Expand All @@ -205,7 +205,7 @@ export class ConnectArray extends ControlContainer implements OnInit {
});
}

private transform(parent: FormGroup | FormArray, reference): AbstractControl {
private transform(parent: FormGroup | FormArray, reference: any): AbstractControl {
const emptyControl = () => {
const control = new FormControl(null);
control.setParent(parent);
Expand All @@ -227,7 +227,7 @@ export class ConnectArray extends ControlContainer implements OnInit {
return emptyControl();
}

const iterate = (iterable): FormArray => {
const iterate = (iterable: any): FormArray => {
const array = new FormArray([]);

this.registerInternals(array);
Expand All @@ -246,7 +246,7 @@ export class ConnectArray extends ControlContainer implements OnInit {
return array;
}

const associate = (value): FormGroup => {
const associate = (value: any): FormGroup => {
const group = new FormGroup({});
group.setParent(parent);

Expand Down Expand Up @@ -280,7 +280,7 @@ export class ConnectArray extends ControlContainer implements OnInit {

private simpleAccessor() {
return {
writeValue: value => this.control.setValue(value),
writeValue: (value: any) => this.control.setValue(value),
registerOnChange() {},
registerOnTouched() {}
};
Expand Down
10 changes: 6 additions & 4 deletions source/connect-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ConnectBase {

private formSubscription: Subscription;
protected store: FormStore;
protected form;
protected form: any;

public get path(): Array<string> {
const path = typeof this.connect === 'function'
Expand Down Expand Up @@ -68,12 +68,14 @@ export class ConnectBase {
this.stateSubscription = this.store.subscribe(() => this.resetState());

Promise.resolve().then(() => {
this.formSubscription = (<any>this.form.valueChanges).debounceTime(0).subscribe(values => this.publish(values));
this.formSubscription = (<any>this.form.valueChanges)
.debounceTime(0)
.subscribe((values: any) => this.publish(values));
});
});
}

private descendants(path: Array<string>, formElement): Array<ControlPair> {
private descendants(path: Array<string>, formElement: any): Array<ControlPair> {
const pairs = new Array<ControlPair>();

if (formElement instanceof FormArray) {
Expand Down Expand Up @@ -122,7 +124,7 @@ export class ConnectBase {
});
}

private publish(value) {
private publish(value: any) {
this.store.valueChanged(this.path, this.form, value);
}

Expand Down
2 changes: 1 addition & 1 deletion source/connect-reactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {ConnectBase} from './connect-base';
// For reactive forms (without implicit NgForm)
@Directive({ selector: 'form[connect][formGroup]' })
export class ReactiveConnect extends ConnectBase {
@Input('formGroup') form;
@Input('formGroup') form: any;

constructor(
protected store: FormStore
Expand Down
2 changes: 1 addition & 1 deletion source/form-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {FORM_CHANGED} from './form-store';
import {State} from './state';

export const defaultFormReducer = <RootState>(initialState?: RootState | Iterable.Keyed<string, any>) => {
const reducer = (state: RootState | Iterable.Keyed<string, any> = initialState, action: Action & {payload?}) => {
const reducer = (state: RootState | Iterable.Keyed<string, any> | undefined = initialState, action: Action & {payload?: any}) => {
switch (action.type) {
case FORM_CHANGED:
return State.assign(
Expand Down
4 changes: 2 additions & 2 deletions source/form-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Action, Unsubscribe} from 'redux';

export interface AbstractStore<RootState> {
/// Dispatch an action
dispatch(action: Action & {payload}): void;
dispatch(action: Action & {payload: any}): void;

/// Retrieve the current application state
getState(): RootState;
Expand All @@ -34,7 +34,7 @@ export class FormStore {
return this.store.getState();
}

subscribe(fn: (state) => void): Unsubscribe {
subscribe(fn: (state: any) => void): Unsubscribe {
return this.store.subscribe(() => fn(this.getState()));
}

Expand Down
8 changes: 4 additions & 4 deletions source/shims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export function controlPath(name: string, parent: ControlContainer): string[] {
}

export function selectValueAccessor(
dir: NgControl, valueAccessors: ControlValueAccessor[]): ControlValueAccessor {
dir: NgControl, valueAccessors: ControlValueAccessor[]): ControlValueAccessor | null {
if (!valueAccessors) return null;

let defaultAccessor: ControlValueAccessor;
let builtinAccessor: ControlValueAccessor;
let customAccessor: ControlValueAccessor;
let defaultAccessor: ControlValueAccessor | null = null;
let builtinAccessor: ControlValueAccessor | null = null;
let customAccessor: ControlValueAccessor | null = null;
valueAccessors.forEach((v: ControlValueAccessor) => {
if (v.constructor === DefaultValueAccessor) {
defaultAccessor = v;
Expand Down
38 changes: 19 additions & 19 deletions source/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ export interface Operations<T> {
clone(): T;

/// Clone and merge
merge(key: number | string, value: T);
merge(key: number | string | null, value: T): any;

/// Clone the object and update a specific key inside of it
update(key: number | string, value: T);
update(key: number | string | null, value: T): any;
}

export interface TraverseCallback {
(parent, key: number | string, remainingPath: string[], value?);
(parent: any, key: number | string, remainingPath: string[], value?: any): any;
}

export abstract class State {
Expand All @@ -37,7 +37,7 @@ export abstract class State {
deepValue = (<Map<string, any>> <any> deepValue).get(k);
}
else {
deepValue = deepValue[k];
deepValue = (deepValue as any)[k];
}

if (typeof fn === 'function') {
Expand All @@ -64,7 +64,7 @@ export abstract class State {
return State.traverse(state, path);
}

static assign<State>(state: State, path: string[], value?) {
static assign<State>(state: State, path: string[], value?: any) {
const operations = State.inspect(state);

if (path.length === 0) {
Expand Down Expand Up @@ -117,7 +117,7 @@ export abstract class State {
}

static inspect<K>(object: K): Operations<K> {
const metaOperations = (update, merge, clone?) => {
const metaOperations = (update: Function, merge: Function, clone?: Function) => {
const operations = {
/// Clone the object (shallow)
clone: typeof clone === 'function'
Expand All @@ -130,7 +130,7 @@ export abstract class State {
/// Merge existing values with new values
merge: (key: string, value: K) => {
const cloned = operations.clone();
return merge(cloned, key, value, v => update(cloned, key, v));
return merge(cloned, key, value, (v: any) => update(cloned, key, v));
}
};

Expand All @@ -140,7 +140,7 @@ export abstract class State {
if (Iterable.isIterable(object)) {
return metaOperations(
// Replace
(parent, key: number | string, value: K) => {
(parent: any, key: number | string, value: K) => {
if (key != null) {
return parent.set(key, value);
}
Expand All @@ -149,7 +149,7 @@ export abstract class State {
}
},
// Merge
(parent, key: number | string | string[], value: K) => {
(parent: any, key: number | string | string[], value: K) => {
if (key) {
return parent.mergeDeepIn(Array.isArray(key) ? key : [key], value);
}
Expand All @@ -166,7 +166,7 @@ export abstract class State {
else if (Array.isArray(object)) {
return metaOperations(
// Replace array contents
(parent, key: number, value: K) => {
(parent: any, key: number, value: K) => {
if (key != null) {
parent[key] = value;
}
Expand All @@ -177,7 +177,7 @@ export abstract class State {
},

// Merge
(parent, _, value: K, setter: (v: K) => K) => {
(parent: any, _: any, value: K, setter: (v: K) => K) => {
setter(parent.concat(value));
return parent;
},
Expand All @@ -189,7 +189,7 @@ export abstract class State {
else if (object instanceof Map) {
return metaOperations(
// Update map key
(parent, key: number | string, value: K) => {
(parent: any, key: number | string, value: K) => {
if (key != null) {
return parent.set(key, value);
}
Expand All @@ -202,7 +202,7 @@ export abstract class State {
},

// Merge
(parent: Map<string, any>, _, value: K) => {
(parent: Map<string, any>, _: any, value: K) => {
const m = new Map<string, any>(<any> value);
m.forEach((value, key) => parent.set(key, value));
return parent;
Expand All @@ -217,7 +217,7 @@ export abstract class State {
else if (object instanceof WeakSet || object instanceof Set) {
return metaOperations(
// Update element at index in set
(parent, key: number, value: K) => {
(parent: any, key: number, value: K) => {
if (key != null) {
return parent.set(key, value);
}
Expand All @@ -230,7 +230,7 @@ export abstract class State {
},

// Merge
(parent: Set<any>, _, value) => {
(parent: Set<any>, _: any, value: any) => {
for (const element of value) {
parent.add(element);
}
Expand Down Expand Up @@ -260,15 +260,15 @@ export abstract class State {
break;
}
return metaOperations(
(parent, key, value: K) => {
(parent: any, key: any, value: K) => {
if (key != null) {
return Object.assign(parent, {[key]: value});
}
return Object.assign(parent, value);
},
(parent, _, value: K) => {
(parent: any, _: any, value: K) => {
for (const k of Object.keys(value)) {
parent[k] = value[k];
parent[k] = (value as any)[k];
}
return parent;
},
Expand All @@ -284,7 +284,7 @@ export abstract class State {
'in the mutation path should be an array, an associative container, or a set');
}

static empty(value): boolean {
static empty(value: any): boolean {
return value == null
|| (value.length === 0
|| (typeof value.length === 'undefined' && Object.keys(value).length === 0));
Expand Down
Loading