Skip to content

Commit

Permalink
fix(types): disable allowSyntheticDefaultImports
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlangelaan committed Aug 30, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 5a62f3a commit 9c39a47
Showing 22 changed files with 56 additions and 50 deletions.
4 changes: 2 additions & 2 deletions packages/hn-react/src/components/DrupalPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import renderer from 'react-test-renderer';
import * as React from 'react';
import * as renderer from 'react-test-renderer';
import site from '../utils/site';
import { asyncMapper, mapper, uuid, uuid2 } from '../utils/tests';
import waitForHnData from '../utils/waitForHnData';
9 changes: 5 additions & 4 deletions packages/hn-react/src/components/DrupalPage.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import getNested from 'get-nested';
import { Site } from 'hn';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import * as PropTypes from 'prop-types';
import * as React from 'react';
import { SiteConsumer } from '../context/site';
import EntityMapper, {
EntityMapper as InnerEntityMapper,
} from './EntityMapper';

class DrupalPage extends Component<
const getNested = require('get-nested'); // tslint:disable-line:no-var-requires

class DrupalPage extends React.Component<
DrupalPageProps & { site: Site },
DrupalPageState
> {
4 changes: 2 additions & 2 deletions packages/hn-react/src/components/EntityListMapper.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import renderer from 'react-test-renderer';
import * as React from 'react';
import * as renderer from 'react-test-renderer';
import site from '../utils/site';
import { asyncMapper, mapper, uuid } from '../utils/tests';
import waitForHnData from '../utils/waitForHnData';
6 changes: 3 additions & 3 deletions packages/hn-react/src/components/EntityListMapper.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types';
import React, { Fragment } from 'react';
import * as PropTypes from 'prop-types';
import * as React from 'react';
import EntityMapper, { EntityMapperPropsMapper } from './EntityMapper';

const EntityListMapper: React.StatelessComponent<EntityListMapperProps> = ({
@@ -10,7 +10,7 @@ const EntityListMapper: React.StatelessComponent<EntityListMapperProps> = ({
asyncMapper,
}: any): any =>
entities.map((ref, index) => {
const EntityWrapper = entityWrapper || Fragment;
const EntityWrapper = entityWrapper || React.Fragment;
const uuid = isEntityReferenceField(ref) ? ref.target_uuid : ref;

return (
4 changes: 2 additions & 2 deletions packages/hn-react/src/components/EntityMapper.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import renderer from 'react-test-renderer';
import * as React from 'react';
import * as renderer from 'react-test-renderer';
import site from '../utils/site';
import {
asyncMapper,
15 changes: 8 additions & 7 deletions packages/hn-react/src/components/EntityMapper.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import getNested from 'get-nested';
import { Site } from 'hn';
import PropTypes from 'prop-types';
import React, { ReactType } from 'react';
import * as PropTypes from 'prop-types';
import * as React from 'react';
import { SiteConsumer } from '../context/site';

const getNested = require('get-nested'); // tslint:disable-line:no-var-requires

export class EntityMapper extends React.Component<
EntityMapperProps & { site: Site },
EntityMapperState
@@ -233,14 +234,14 @@ export class EntityMapper extends React.Component<
}

export interface ObjectMapper {
[uuid: string]: ReactType;
[uuid: string]: React.ReactType;
}
export interface ObjectMapperAsync {
[uuid: string]: () => Promise<ReactType>;
[uuid: string]: () => Promise<React.ReactType>;
}

export type functionMapper = (entity: object) => ReactType;
export type functionMapperAsync = (entity: object) => Promise<ReactType>;
export type functionMapper = (entity: object) => React.ReactType;
export type functionMapperAsync = (entity: object) => Promise<React.ReactType>;

export type mapperType =
| ObjectMapper
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import renderer from 'react-test-renderer';
import * as React from 'react';
import * as renderer from 'react-test-renderer';
import site from '../../utils/site';
import { mapper, uuid } from '../../utils/tests';
import waitForHnData from '../../utils/waitForHnData';
7 changes: 4 additions & 3 deletions packages/hn-react/src/components/deprecated/Paragraph.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import PropTypes from 'prop-types';
import React from 'react';
import deprecate from 'util-deprecate';
import * as PropTypes from 'prop-types';
import * as React from 'react';
import EntityMapper from '../EntityMapper';

const deprecate = require('util-deprecate'); // tslint:disable-line:no-var-requires

const Paragraph: React.StatelessComponent<ParagraphProps> = ({
mapper,
uuid,
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import renderer from 'react-test-renderer';
import * as React from 'react';
import * as renderer from 'react-test-renderer';
import site from '../../utils/site';
import { mapper, uuid } from '../../utils/tests';
import waitForHnData from '../../utils/waitForHnData';
7 changes: 4 additions & 3 deletions packages/hn-react/src/components/deprecated/Paragraphs.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import PropTypes from 'prop-types';
import React from 'react';
import deprecate from 'util-deprecate';
import * as PropTypes from 'prop-types';
import * as React from 'react';
import EntityListMapper from '../EntityListMapper';

const deprecate = require('util-deprecate'); // tslint:disable-line:no-var-requires

const Paragraphs: React.StatelessComponent<ParagraphsProps> = ({
mapper,
paragraphs,
6 changes: 3 additions & 3 deletions packages/hn-react/src/context/site.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Site } from 'hn';
import React, { Component } from 'react';
import renderer from 'react-test-renderer';
import * as React from 'react';
import * as renderer from 'react-test-renderer';
import site from '../utils/site';
import { SiteConsumer, SiteProvider, withSite } from './site';

@@ -76,7 +76,7 @@ describe('withSite', async () => {
// @ts-ignore
@withSite
// @ts-ignore
class Consumer extends Component<{ site: Site }> {
class Consumer extends React.Component<{ site: Site }> {
render() {
renderedSite = this.props.site;
return null;
6 changes: 3 additions & 3 deletions packages/hn-react/src/context/site.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Site } from 'hn';
import React, { createContext, ReactNode } from 'react';
import * as React from 'react';
import globalSite from '../utils/site';

// Create a new context.
const { Provider, Consumer } = createContext(globalSite);
const { Provider, Consumer } = React.createContext(globalSite);

// The site provider is the same as the 'Provider', but changes 'site' to
// 'value'.
@@ -12,7 +12,7 @@ export const SiteProvider = ({
children,
}: {
site: Site;
children: ReactNode;
children: React.ReactNode;
}) => <Provider value={site} children={children} />;

// The consumer is exported as both Site and SiteConsumer. The SiteConsumer can
2 changes: 1 addition & 1 deletion packages/hn-react/src/utils/tests/components/HOC.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';

export default WrappedComponent => props => (
<WrappedComponent {...props} hocProps />
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import React from 'react';
import * as React from 'react';

export default props => <div className="MyCustomMapperComponent" {...props} />;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import HOC from './HOC';

export default HOC(props => (
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import HOC from './HOC';

export default HOC(props => (
2 changes: 1 addition & 1 deletion packages/hn-react/src/utils/tests/index.ts
Original file line number Diff line number Diff line change
@@ -68,5 +68,5 @@ export class SiteMock {
}

export function mockSite() {
return new SiteMock();
return { default: new SiteMock() };
}
9 changes: 5 additions & 4 deletions packages/hn-react/src/utils/waitForHnData.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import asyncBootstrapper from 'react-async-bootstrapper';
import * as PropTypes from 'prop-types';
import * as React from 'react';

const asyncBootstrapper = require('react-async-bootstrapper'); // tslint:disable-line:no-var-requires

export default async function(children) {
const context = {
@@ -10,7 +11,7 @@ export default async function(children) {
},
};

class DrupalPageContextProvider extends Component {
class DrupalPageContextProvider extends React.Component {
static childContextTypes = {
hnContext: PropTypes.object,
};
4 changes: 3 additions & 1 deletion packages/hn-react/types/react-async-bootstrapper/index.d.ts
Original file line number Diff line number Diff line change
@@ -3,8 +3,10 @@ declare module 'react-async-bootstrapper' {
componentWillUnmount?: boolean;
}

export default function asyncBootstrapper(
function asyncBootstrapper(
reactElement: JSX.Element,
options: AsyncBootstrapperOptions,
): Promise<JSX.Element>;

export = asyncBootstrapper;
}
4 changes: 2 additions & 2 deletions packages/hn/src/Site.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import deepmerge from 'deepmerge';
import getNested from 'get-nested';
import * as deepmerge from 'deepmerge';
import 'isomorphic-fetch';
import { stringify } from 'query-string';
import HnServerResponse, { HnData } from './HnServerResponse';
import SiteInitializeParams from './SiteInitializeParams';
const getNested = require('get-nested'); // tslint:disable-line:no-var-requires

const propertiesToHydrate = ['tokensToVerify', 'user', 'data'];

2 changes: 1 addition & 1 deletion packages/hn/src/__tests__/site.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fetchMock from 'fetch-mock';
import * as fetchMock from 'fetch-mock';
import { parse } from 'url';
import { Site } from '..';

1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@
"inlineSourceMap": false,
"declaration": true,
"jsx": "react",
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"baseUrl": "./packages",
"paths": {

0 comments on commit 9c39a47

Please sign in to comment.