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

Types don't use unique symbol type #41

Closed
pittst3r opened this issue Oct 14, 2018 · 3 comments
Closed

Types don't use unique symbol type #41

pittst3r opened this issue Oct 14, 2018 · 3 comments

Comments

@pittst3r
Copy link

pittst3r commented Oct 14, 2018

Consumers of this library may do something like this:

import $$observable from 'symbol-observable';

export class Foo {
  [$$observable]() {
    return this;
  }
}

If using TypeScript their output .d.ts will look like the following, because $$observable is not a unique symbol:

export declare class Foo {
}

However, if we use the unique symbol type the output .d.ts will be:

import $$observable from 'symbol-observable';
export declare class Foo {
   [$$observable](): this;
}

This allows improves interop between observable interfaces with regards to typing (rxjs and xstream in my case). There are unfortunately more issues between rxjs and xstream; namely the Subscribable interfaces.

Would you accept a PR amending the types to use the unique symbol type? Note that using unique symbol would require a TS upgrade to ~2.7.0 and an update to rxjs so as to not regress ReactiveX/rxjs#3697.

@benlesh
Copy link
Owner

benlesh commented Jul 9, 2020

This apparently is also at odds with @types/node, so we can't really make this fix until it's either fixed or removed there.

@benlesh
Copy link
Owner

benlesh commented Nov 2, 2020

Also of note: symbol-observable@3.0.0 is updated to publish types for Symbol.observable as being unique symbol as well.

@skipjack
Copy link

skipjack commented Mar 18, 2021

I'm still seeing this issue with symbol-observable@3.0.0 and @types/node@14.14.35...

Error: node_modules/symbol-observable/index.d.ts:6:14 - error TS2717: Subsequent property declarations must have the same type.  Property 'observable' must be of type 'symbol', but here has type 'unique symbol'.

6     readonly observable: unique symbol;
               ~~~~~~~~~~

  node_modules/@types/node/globals.d.ts:146:14
    146     readonly observable: symbol;
                     ~~~~~~~~~~
    'observable' was also declared here.

Update: Installing an older 2.x version of this package as noted in apollographql/apollo-client#7337 fixed the issue, still unsure why the latest of both wouldn't work though. Lmk if you'd like me to create a separate issue.

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

3 participants