Skip to content
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

Fix typings #5

Open
kwisatz opened this issue Nov 11, 2019 · 3 comments
Open

Fix typings #5

kwisatz opened this issue Nov 11, 2019 · 3 comments

Comments

@kwisatz
Copy link
Member

kwisatz commented Nov 11, 2019

The typings need to be fixed in order to enable TypeScript support for lonad.
Currently, using lonad with typings will lead to erroneous tslint.

@floriansimon1
Copy link
Collaborator

Do you have problems only with Result, or with Optional too?

@kwisatz
Copy link
Member Author

kwisatz commented Nov 11, 2019

Optional too. Without disclosing too much of the project:

***.ts:293:5 - error TS2739: Type 'Optional<unknown>' is missing the following properties from type '{ folder: string; created: boolean; }': folder, created

293     return Optional.None();
        ~~~~~~~~~~~~~~~~~~~~~~~

***.ts:302:3 - error TS2739: Type 'Optional<{ folder: string; created: boolean; }>' is missing the following properties from type '{ folder: string; created: boolean; }': folder, created

302   return Optional
      ~~~~~~~~~~~~~~~
303   .fromNullable(subfolders.find(subFolder => {
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... 
310     };
    ~~~~~~
311   });
    ~~~~~

***.ts:317:11 - error TS2345: Argument of type 'unknown' is not assignable to parameter of type 'any[]'.
  Type '{}' is missing the following properties from type 'any[]': length, pop, push, concat, and 28 more.

317           evaluatedExtraTemplateBccs
              ~~~~~~~~~~~~~~~~~~~~~~~~~~

***.ts:265:25 - error TS2314: Generic type 'Optional<T>' requires 1 type argument(s).

265       existingDocument: Optional,
                            ~~~~~~~~

***.ts:410:11 - error TS2322: Type 'Optional<Optional<Moment>>' is not assignable to type 'Optional<Moment>'.
  Type 'Optional<Moment>' is missing the following properties from type 'Moment': format, startOf, endOf, add, and 76 more.

410     const optionalStart: Optional<Moment> = Optional
              ~~~~~~~~~~~~~

***.ts:424:11 - error TS2322: Type 'Optional<Optional<Moment>>' is not assignable to type 'Optional<Moment>'.

424     const optionalEnd: Optional<Moment> = Optional
              ~~~~~~~~~~~

***.ts:125:21 - error TS2339: Property 'filter' does not exist on type 'unknown'.

125     maxBy(contracts.filter(unlimited), prop('start'))
                        ~~~~~~

***.ts:138:17 - error TS2339: Property 'find' does not exist on type 'unknown'.

138       contracts.find(contract => {
                    ~~~~

***.ts:152:15 - error TS2339: Property 'push' does not exist on type 'unknown'.

152     contracts.push(contract);
                  ~~~~

***.ts:164:7 - error TS2345: Argument of type 'unknown' is not assignable to parameter of type 'Contract[]'.
  Type '{}' is missing the following properties from type 'Contract[]': length, pop, push, concat, and 28 more.

164       contracts
          ~~~~~~~~~

***.ts:205:4 - error TS2554: Expected 1 arguments, but got 0.

205   .getOrElse();
       ~~~~~~~~~~~

  ../../../node_modules/lonad/index.d.ts:36:16
    36   getOrElse<U>(replacement: U):                            T | U;
                      ~~~~~~~~~~~~~~
    An argument for 'replacement' was not provided.

***.ts:275:14 - error TS2554: Expected 2 arguments, but got 1.

275     Optional.when(!cumulate || (cumulate && shouldRecordBeAccumulated(currentRecord)))
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  ../../../node_modules/lonad/index.d.ts:61:24
    61   when<T>(truthy: any, value: T):                   Optional<T>;
                              ~~~~~~~~
    An argument for 'value' was not provided.

***.ts:59:25 - error TS2339: Property 'filter' does not exist on type 'unknown'.

59     maxBy(weekTemplates.filter(unlimited), prop('start'))
                           ~~~~~~

***.ts:71:23 - error TS2339: Property 'push' does not exist on type 'unknown'.

71         weekTemplates.push(makeWeekTemplate(Object.assign(
                         ~~~~

***.ts:78:21 - error TS2339: Property 'push' does not exist on type 'unknown'.

78       weekTemplates.push(makeWeekTemplate(Object.assign(
                       ~~~~

***.ts:139:8 - error TS2554: Expected 2 arguments, but got 1.

139       .when(this.cumulate)
           ~~~~~~~~~~~~~~~~~~~

  ../../../node_modules/lonad/index.d.ts:61:24
    61   when<T>(truthy: any, value: T):                   Optional<T>;
                              ~~~~~~~~
    An argument for 'value' was not provided.

@floriansimon1
Copy link
Collaborator

That sounds like a lot of work to fix. Sorry for the initial shortcomings of the library. I can fix this over time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants