19 Commits

Author SHA1 Message Date
c2c49c5f7a Record actions before rendering 2019-09-11 10:14:56 +07:00
fdbe4be75f Return waitForActions after rendering 2019-09-11 10:13:34 +07:00
055d9588bf Use JSONRPC in TeamService (needs more testing) 2019-09-11 00:40:10 +07:00
eebe26f706 Extract redux, http-types, http-client and test-utils 2019-09-10 17:56:25 +07:00
6a456eb6e8 Fix broken tests 2019-09-01 15:40:34 +07:00
45f0cb76d3 Fix return type of withJSX (used to be any) 2019-06-04 14:58:41 +10:00
18fef76807 Add ability to login from embedded site 2019-04-15 00:13:51 +12:00
264f5aba60 Add T prefix for all type defs 2019-04-02 16:22:38 +08:00
d3f294a57c Add packages/client/src/crumbs 2019-03-25 18:30:32 +08:00
3595a71cec Make TestUtils.tsx type safe
After spending almost two days in finding the issue, I ran across a few
TypeScript issues on their GitHub page:

- Loss of type inference converting to named parameters object
  https://github.com/Microsoft/TypeScript/issues/29791

- Parameter of a callback without a specified type next to it breaks code.
  https://github.com/Microsoft/TypeScript/issues/29799

- Convert to named parameters
  https://github.com/Microsoft/TypeScript/pull/30089

It became clear that TypeScript is unable to infer method return
arguments if a generic type is used more than once in generic parameter
object. Instead it returns {}.

For example, the following would fail on line 28:

    type Convert<A, B> = (value: A) => B

    interface IParams<C, D> {
      value: C
      convert: Convert<C, D>
      doConvert: (value: C, convert: this['convert']) => D
    }

    function doSomething<E, F>(value: E, convert: Convert<E, F>) {
      return convert(value)
    }

    function build<G, H>(params: IParams<G, H>) {
      const {value, convert} = params
      return params.doConvert(value, convert)
    }

    const outerResult = build({
      value: {
        a: {
          value: 1,
        },
        b: 'string',
      },
      convert: value => value.a,
      doConvert: (value, convert) => {
        const innerResult = doSomething(value, convert)
        innerResult.value
        console.log('innerResult:', innerResult)
        return innerResult
      },
    })

    console.log('outerResult:', outerResult)

With the message:

    Property 'value' does not exist on type '{}'.

If we replace parameter object IParams with regular ordered function
parameters, the compilation succeeds.

RyanCavanough (TS project lead) from GitHub commented:

> We don't have a separate pass to say "Go dive into the function and
> check to see if all its return statements don't rely on its parameter
> type" - doing so would be expensive in light of the fact that extremely
> few real-world functions actually behave like that in practice.

Source: https://github.com/Microsoft/TypeScript/issues/29799#issuecomment-464154659

These modifications bring type safety to TestUtils.tsx, and therefore
client-side tests of React components, while keeping almost the same
ease of use as before.
2019-03-23 15:48:52 +08:00
637b51382a Fix broken LoginForm.test.tsx 2019-03-22 14:43:43 +08:00
8ae82c5065 Add ability to specify custom JSX in TestUtils 2019-03-20 15:28:05 +05:00
003bccc9e8 projects/node: Add custom redirectTo after successful login 2019-03-18 13:13:52 +05:00
360dc83ded Setup simple SSR, untested 2019-03-14 12:38:34 +05:00
6c2728228e Add render to comments-client 2019-03-13 19:07:49 +05:00
3257a6ffb4 Extract createStore into a separate module 2019-03-13 16:46:55 +05:00
6ee5077c88 Add documentation 2019-01-20 22:47:15 +01:00
5c847b94e6 Add full test for LoginForm 2019-01-20 21:39:32 +01:00
bdf0aa57be Add TestUtils and a generic way to isolate connected components 2019-01-20 18:11:18 +01:00