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

[api] Multiple compile errors related to IGet<K, V> #88

Closed
andrew8er opened this issue Jun 3, 2019 · 5 comments
Closed

[api] Multiple compile errors related to IGet<K, V> #88

andrew8er opened this issue Jun 3, 2019 · 5 comments

Comments

@andrew8er
Copy link
Contributor

I get multiple errors in package @thi.ng/associative:

node_modules/@thi.ng/associative/array-set.d.ts:18:5 - error TS2416: Property 'copy' in type 'ArraySet<T>' is not assignable to the same property in base type 'IEquivSet<T>'.
  Type '() => ArraySet<T>' is not assignable to type '() => IEquivSet<T>'.
    Type 'ArraySet<T>' is not assignable to type 'IEquivSet<T>'.
      Types of property 'get' are incompatible.
        Type '(x: T, notFound?: T | undefined) => T | undefined' is not assignable to type '(key: T, notfound?: T | undefined) => T'.
          Type 'T | undefined' is not assignable to type 'T'.
            Type 'undefined' is not assignable to type 'T'.

18     copy(): ArraySet<T>;
       ~~~~

I think the reason is an incorrect return type in IGet.get(), it should be V | undefined:

// @thi.ng/api/api.d.ts:
export interface IGet<K, V> {
    get(key: K, notfound?: V): V | undefined;
}
@postspectacular
Copy link
Member

Hi @andrew8er - let me guess, you're having some TS "strict" compiler flags enabled? Coincidentally I've recently done some initial work on a local feature branch to finally enable "strict" (minus "strictNullChecks", which I find too intensive to fully support right now). Only updated around a dozen of the 90 packages in total so far, but will merge WIP into develop branch..

@andrew8er
Copy link
Contributor Author

Yes, I always use strict, including strictNullChecks. I really think it forces me to write better code. Do you need some help?

@postspectacular
Copy link
Member

Thanks, @andrew8er - I will push the updates done so far later today and if you've got time would very much appreciate your watchful eye passing over them and maybe even help w/ updating the rest. Have done some more last night and guessing around 50% done so far...

In general, I'm all for enabling strict (hence why I started already on this), but am also pragmatic (coming from Clojure) and went for low hanging fruits only so far...

@andrew8er
Copy link
Contributor Author

I think you are referring to branch feature/strict? I will have a look at it. I only used @thi.ng/rstream and @thi.ng/transducers so far, so I might be most helpful with these.

@postspectacular
Copy link
Member

postspectacular commented Jun 5, 2019

Well, yes, with pushing updates, I did mean the #89 PR (feature/strict branch), but generally I was referring to the strict compiler flag. Btw. all packages are now updated with more type hints and in some cases minor new type additions, so yarn build will succeed now on that branch (with strict flag enabled for all). I started updating the tests too, but prob will take me another few days...

postspectacular added a commit that referenced this issue Jun 11, 2019
* develop: (144 commits)
  refactor(examples): update all examples
  fix(interceptors): update EventBus ctor args
  fix(hdom-components): update CanvasHandler args
  feat(csp): update Mult.tap() to use set semantics
  test: update various tests for TS strictNullChecks
  fix(unionstruct): allow undefined/null args
  fix(iterators): update concat/mapcat, fnil args
  refactor(diff): allow args to be undefined/null
  build: enable strictNullChecks for all packages
  refactor(hiccup-markdown): TS strictNullChecks, add tests
  fix(fsm): callback return types
  refactor(sax): TS strictNullChecks
  feat(color): TS strictNullChecks, update color conversion fns
  refactor(associative): TS strictNullChecks, fix #88
  refactor(rstream-query): TS strictNullChecks
  refactor(rstream-log): TS strictNullChecks
  refactor(rstream-graph): TS strictNullChecks
  refactor(rstream-gestures): TS strictNullChecks
  refactor(rstream-dot): TS strictNullChecks
  fix(rstream): TS strictNullChecks, add assertions
  ...
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