Skip to content

Commit

Permalink
Road to noImplicitAny part 6 (FINAL part) (#4508)
Browse files Browse the repository at this point in the history
## What this PR is about?
Finally all strict rules are enables for TypeScript compiler! 🎉 Basically previously `noImplicitAny` was turned off but now it plus all strict rules are turned ON! 💋 

## Some highlights of the changes
- `Element` renamed internally to `SharedElement` to make more sense what is it
- `LayoutTreeParser`'s responsibility is now to do all `id` related stuff. Previously it was spread between `LayoutTreeCrawler` and `LayoutTreeParse` so it is more simple now
- clean up a lot of tests because they were testing duplicate stuff that was covered by other tests already
- removed all usages of `static get options` and replaces them with `static options`. This is how it is in the docs plus you cannot have `static get options(passProps)` because it is impossible to have getter with parameters.
  • Loading branch information
henrikra authored and guyca committed Jan 6, 2019
1 parent 53830af commit 08f8581
Show file tree
Hide file tree
Showing 31 changed files with 450 additions and 504 deletions.
15 changes: 7 additions & 8 deletions lib/src/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { LayoutTreeParser } from './commands/LayoutTreeParser';
import { LayoutTreeCrawler } from './commands/LayoutTreeCrawler';
import { EventsRegistry } from './events/EventsRegistry';
import { ComponentProvider } from 'react-native';
import { Element } from './adapters/Element';
import { SharedElement } from './adapters/SharedElement';
import { CommandsObserver } from './events/CommandsObserver';
import { Constants } from './adapters/Constants';
import { ComponentEventsObserver } from './events/ComponentEventsObserver';
Expand All @@ -23,9 +23,10 @@ import { AssetService } from './adapters/AssetResolver';
import { AppRegistryService } from './adapters/AppRegistryService';

export class NavigationRoot {
public readonly Element: React.ComponentType<{ elementId: any; resizeMode?: any; }>;
public readonly TouchablePreview: React.ComponentType<any>;
public readonly store: Store;
public readonly Element = SharedElement;
public readonly TouchablePreview = TouchablePreview;

private readonly store: Store;
private readonly nativeEventsReceiver: NativeEventsReceiver;
private readonly uniqueIdProvider: UniqueIdProvider;
private readonly componentRegistry: ComponentRegistry;
Expand All @@ -39,8 +40,6 @@ export class NavigationRoot {
private readonly componentWrapper: ComponentWrapper;

constructor() {
this.Element = Element;
this.TouchablePreview = TouchablePreview;
this.componentWrapper = new ComponentWrapper();
this.store = new Store();
this.nativeEventsReceiver = new NativeEventsReceiver();
Expand All @@ -53,9 +52,9 @@ export class NavigationRoot {
this.componentWrapper,
appRegistryService
);
this.layoutTreeParser = new LayoutTreeParser();
this.layoutTreeParser = new LayoutTreeParser(this.uniqueIdProvider);
const optionsProcessor = new OptionsProcessor(this.store, this.uniqueIdProvider, new ColorService(), new AssetService());
this.layoutTreeCrawler = new LayoutTreeCrawler(this.uniqueIdProvider, this.store, optionsProcessor);
this.layoutTreeCrawler = new LayoutTreeCrawler(this.store, optionsProcessor);
this.nativeCommandsSender = new NativeCommandsSender();
this.commandsObserver = new CommandsObserver(this.uniqueIdProvider);
this.commands = new Commands(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import * as React from 'react';
import * as PropTypes from 'prop-types';
import { requireNativeComponent } from 'react-native';

export class Element extends React.Component<{ elementId: string; resizeMode?: string }> {
export interface SharedElementProps {
elementId: string;
resizeMode: string;
}

export class SharedElement extends React.Component<SharedElementProps> {
static propTypes = {
elementId: PropTypes.string.isRequired,
resizeMode: PropTypes.string
Expand All @@ -13,10 +18,10 @@ export class Element extends React.Component<{ elementId: string; resizeMode?: s
};

render() {
return <RNNElement {...this.props} />;
return <RnnSharedElement {...this.props} />;
}
}

const RNNElement = requireNativeComponent('RNNElement', Element, {
const RnnSharedElement = requireNativeComponent('RNNElement', SharedElement, {
nativeOnly: { nativeID: true }
});
5 changes: 0 additions & 5 deletions lib/src/adapters/UniqueIdProvider.mock.ts

This file was deleted.

Loading

0 comments on commit 08f8581

Please sign in to comment.