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

error TS2585: 'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the lib compiler option to es2015 or later. #4448

Closed
EvanCarroll opened this issue Jan 2, 2019 · 11 comments

Comments

@EvanCarroll
Copy link

Bug Report

error TS2585: 'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the lib compiler option to es2015 or later.

Current Behavior

node_modules/rxjs/internal/Observable.d.ts:82:59 - error TS2585: 'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.                                                                   

82     toPromise<T>(this: Observable<T>, PromiseCtor: typeof Promise): Promise<T>;                                                                    
                                                             ~~~~~~~


Found 1 error.

Reproduction

  • REPL or Repo link:

https://stackoverflow.com/questions/54014405/ts2585-promise-only-refers-to-a-type-but-is-being-used-as-a-value-here?noredirect=1#comment94866023_54014405

Environment

  • Runtime: Node 11.6
  • RxJS version: 6.3.3

see https://stackoverflow.com/questions/54014405/ts2585-promise-only-refers-to-a-type-but-is-being-used-as-a-value-here?noredirect=1#comment94866023_54014405

@cartant
Copy link
Collaborator

cartant commented Jan 2, 2019

If you are targeting an earlier version of JS, you will need a Promise polyfill. That's the source of the problem. RxJS does not include such a polyfill, so the Promise constructor does not exist and the error you reported is effected.

@EvanCarroll
Copy link
Author

EvanCarroll commented Jan 2, 2019

I'm not targeting an earlier version of JS (or trying to anyway), I'm just trying to get things working for node v11.6 which is the newest.

@cartant
Copy link
Collaborator

cartant commented Jan 2, 2019

You should include a minimal repro with the exact settings that see the error effected. The SO question includes more than one set of tsconfig.json properties. TBH, if this is an issue at all, it looks like a TS issue and not an RxJS issue.

@EvanCarroll
Copy link
Author

EvanCarroll commented Jan 3, 2019

Not sure where the complexity is (the se had the conf and the code) but I'm happy to do it.

https://github.com/EvanCarroll/rxjsissue4448

@kwonoj @cartant

@cartant
Copy link
Collaborator

cartant commented Jan 3, 2019

Now remove RxJS from your minimal repro and add the following instead:

type P = typeof Promise;

If the error is still effected, you can close this and report it in the TypeScript repo, instead.

@EvanCarroll
Copy link
Author

Whelp, it is. I'll file the bug in TypeScript.

@EvanCarroll
Copy link
Author

@cartant bug found tsc file.ts does not process typescript.conf

@cartant
Copy link
Collaborator

cartant commented Jan 6, 2019

Yeah, that rings a bell. I think I've been bitten by that behaviour in the past.

@EvanCarroll
Copy link
Author

https://twitter.com/TheEvanCarroll/status/1080899909522477061 (if you care to vote on it)

@reed-lawrence
Copy link

So what was the conclusion here? I'm getting the same error - followed here from stack overflow

@cartant
Copy link
Collaborator

cartant commented Jan 24, 2019

@reed-lawrence The conclusion is that this is - as discussed above - not an RxJS issue.

@ReactiveX ReactiveX locked as resolved and limited conversation to collaborators Jan 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants