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

missing Observable import for visual studio #1696

Closed
wizardnet972 opened this issue May 9, 2016 · 7 comments
Closed

missing Observable import for visual studio #1696

wizardnet972 opened this issue May 9, 2016 · 7 comments

Comments

@wizardnet972
Copy link

wizardnet972 commented May 9, 2016

In every *.d.ts under rx/add,
should add:
import {Observable} from '../../Observable';

for visual studio typescript compiler / intellisense compatibility.

visual studio error message:
Invalid module name in augmentation, module '../../Observable' cannot be found.

for example:

import { BufferSignature } from '../../operator/buffer';
declare module '../../Observable' {
    interface Observable<T> {
        buffer: BufferSignature<T>;
    }
}

should be:

import { BufferSignature } from '../../operator/buffer';
import {Observable} from '../../Observable';
declare module '../../Observable' {
    interface Observable<T> {
        buffer: BufferSignature<T>;
    }
}

based on https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#augmenting-globalmodule-scope-from-modules

@kwonoj
Copy link
Member

kwonoj commented May 9, 2016

I don't think there's strong difference between visual studio to other editor configurations since compilation goes through typescript compiler. Would you be able to share what's tsc version and small code snippet able to reproduce issue?

@fedemarengo
Copy link

@ZenSoftware
Copy link

I wrote the following in a different git repo (apparently it's was the wrong repo to discuss RxJS v5).

Rx Operators Cannot Resolve Observable - Visual Studio 2015 & Typescript

There seems to be a problem with the node module resolutions with all the Rx operators in Visual Studio 2015. No matter what I try, I can not seem to get rid of these typescript errors. For example, when using the RxJS map operator within Angular2 Quickstart package, Visual Studio complains:

Severity: Error
Code: TS2664
Description: Invalid module name in augmentation, module '../../Observable' cannot be found. TypeScript Virtual Projects
Project File: C:\Angular2-Quickstart\node_modules\rxjs\add\operator\map.d.ts
Line: 2

I have several other npm packages that my typescript project does not complain about. Just the RxJS operators. For some reason, when I browse to any type definition file under "node_modules\rxjs\add\operator" all of them are showing the above error on the line with
declare module '../../Observable' {

My project compiles fine using both the typescript's CLI and Visual Studio's built in compiler, but I am getting a flood of these errors in Visual Studio's error window. It also breaks Typescript's intellisense. I have attempted to include a reference path to Rx.KitchenSink. But I just get more of the same errors. Unfortunately nothing seems to be solving this issue.
/// <reference path="../node_modules/rxjs/Rx.KitchenSink.d.ts"/>

My tsconfig.json:

  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  }

My typings.json:

  "ambientDependencies": {
    "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654"
    ...
  }

I am using the latest version of everything:
Windows 10
Visual Studio Enterprise 2015: Version 14.0.25123.00 Update 2
Typescript Version: 1.8.30.0
npm package: "rxjs": "5.0.0-beta.7" (Errors also occurs with 5.0.0-beta.6)
Node: v6.1.0 (I don't think it is relevant, but also occurs on a system with Node v5)

I have a second system with a similar setup, the errors also occur there.

@vladima
Copy link
Contributor

vladima commented May 10, 2016

Please see this thread for a description of the issue and workaround

@ZenSoftware
Copy link

@vladima You are a life saver. Thanks.

@kwonoj
Copy link
Member

kwonoj commented May 10, 2016

Appreciate for workaround @vladima . One of reason I switched from VS is about using typescript.. wish VS15 will enhance support.

Let me close this issue for now since it's tooling environment, @wizardnet972, please reopen / create new issue if there's something unresolved.

@lock
Copy link

lock bot commented Jun 7, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 2018
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

5 participants