Greetings Legends,
So first of all I wanted to say observables are pretty incredible and I have become quite enamored on how the reactiveX team handle them. So more often I find myself trying to implement them for situations. I might still be new, but I just find it fascinating.
That being said,I wanted to construct a small web app that doesn't do angular2. However it would seem that I have ran into a situation, that is quite vexing. My desire was to implement a rxjs subject/observable that would trigger when the server signals it (via websockets) and the other legends over at socket.io graciously made a simple tutorial chat application. So I kind of want to merge the two (socket.io and reactiveX). Now I like typescript for reasons, and would want to implement the script with that. So I have drummed up these files:
tsconfig.json:
{
"compilerOptions": {
"module": "es6",
"moduleResolution": "node",
"target": "es6",
"noImplicitAny": false,
"sourceMap": false
},
"types": [
"rx","es6-shim"
],
"exclude": [
"node_modules"
]
}
typings.json
{
"name": "socket",
"globalDependencies": {
"es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504"
}
}
However whenever I'm trying to do a tsc on a ts file I"m getting an
_node_modules/rxjs/Observable.d.ts(10,66): error TS2304: Cannot find name 'Promise'._
Error. I was reading stuff online however all I getting is a insert this tsd install es6-shim or typings install dt~es6-shim --save --global or something similar to the fact of inserting es6-shim. However I keep getting the same error even with the es6-shim in place. Is there something that went over my head? If you are curious about the dependencies:
"dependencies": {
"@types/es6-promise": "0.0.32",
"@types/rx": "^2.5.33",
"express": "^4.10.2",
"rxjs": "5.0.0-beta.6",
"socket.io": "^1.4.8"
},
"devDependencies": {
"typescript": "^2.0.3",
"typings": "^1.4.0"
}
Thanks for your time
Interesting, I have very exact setup (non-ng2) and it works,
typings.json
https://github.com/kwonoj/rxjs-testscheduler-compat/blob/master/typings.json
tsconfig.json
https://github.com/kwonoj/rxjs-testscheduler-compat/blob/master/tsconfig.json
Thing seems different is types field in your tsconfig.json, but hard to say if it's directly related.
One thing I see is you've installed @types/rx which for < v4, as well as duplicated types between dependencies and typings both (es6-promise and es6-shim) maybe that's reason?
ah one more, please try latest beta (beta.12) instead of b.6. lot of ergonomics has been changed over beta releases.
Thanks for the quick update, unfortunately the results seem to be the same. I tried copying and pasting your typings.json and tsconfig.json files yet same thing. As for the@types, I might I gotten the impression those hold the types def for various libraries, such as rx. But I would assume that is not the case.
One thing I probably forgot to mention is that I have a tsd.json
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"es6-shim/es6-shim.d.ts": {
"commit": "e1a08ca895eb094c075bc7374b13ea1f3680788c"
}
}
}
but I don't think it would hinder anything.
yes, I don't think so. Personally I don't suggest to use in mixture of tsd / typings both (recommend typings only). For now, I can suggest let you try to create minimal repo (rx only, one dummy code use rx, and try to adapt my config) and see if it's reproducible - and let us know that repo to take a quick look.
Rxjs5 (used with angular2) ships with the typescript definitions, so @types/rx is not required, that is for < v4. Removing those first to see what behavior you see would be a good start.
Also Ts2.0 has support to define a specific library, now es6 should trigger the es6 version of the lib, but perhaps there is a bug?
try adding lib: ["es6"] to your tsconfig.config and see what might happen there.
Thanks guys, still no luck tho :(. I'm going to to the minimal repo suggestion kwonoj recommend and see if anything happens. I'll probably get back to you on the status of it in the next day or so.
I have just installed @reactivex/rxjs ^5.0.0-beta.12 and when trying to compile using the tsc compiler, I got many TS2304: Cannot find name 'Promise' errors.
It turns out that you just need to install a definition file for es6-shim, in my case
$ typings install dt~es6-shim --save --global
It might be a good idea to add this to README.
Hey sorry it took so long, out of power due to Matthew. I have done a mock up, with the tsconfig file you provided works with the mock. There are other problems persisting the mock, mainly webpack stuff. But I do believe the ts is compiling correctly with rxjs.
Thanks again.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Rxjs5 (used with angular2) ships with the typescript definitions, so
@types/rxis not required, that is for< v4. Removing those first to see what behavior you see would be a good start.Also Ts2.0 has support to define a specific library, now
es6should trigger thees6version of the lib, but perhaps there is a bug?try adding
lib: ["es6"]to yourtsconfig.configand see what might happen there.