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

Cannot find name 'Fluxxor' && 'Import Fluxxor' - multiple conflicting Intellisense detections #8140

Closed
dbaeumer opened this issue Apr 18, 2016 · 10 comments
Assignees
Labels
Bug A bug in TypeScript Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@dbaeumer
Copy link
Member

From @jwulf on November 24, 2015 12:49

screen shot 2015-11-24 at 10 43 58 pm

Copied from original issue: microsoft/vscode#544

@dbaeumer
Copy link
Member Author

From @jwulf on November 24, 2015 12:51

This is on a Mac.

@dbaeumer
Copy link
Member Author

From @jwulf on November 24, 2015 13:5

Perhaps it is the * as Fluxxor?

import * as Fluxxor from 'fluxxor'

Nope. It's still there with:

import Fluxxor = require('fluxxor');

@dbaeumer
Copy link
Member Author

@jwulf would you be able to share a folder with me that shows the behavior.

@dbaeumer
Copy link
Member Author

From @unional on April 15, 2016 20:51

Just encountered this also.
The code runs fine on tsc but error on vscode (ts language service). Here is how to reproduce:

// s.ts
export class Foo {}

// m.ts
import { Foo } from './s';
declare namespace Foo { };
export = Foo;

// c.ts
import * as Foo from './m';

console.log(Foo);

image

@dbaeumer
Copy link
Member Author

From @unional on April 15, 2016 20:51

Reference:
typed-typings/npm-any-promise#1

@dbaeumer
Copy link
Member Author

From @unional on April 15, 2016 20:57

I tested this on Windows.

Code: 1.0 🎉
Also tested with TypeScript@next using settings.json/typescript.tsdk: 1.9.0-dev.20160415

@dbaeumer
Copy link
Member Author

@unional thanks for the code test case. I am moving this to TS since the seems to be caused by the reexport in m.ts

@sandersn
Copy link
Member

There is an error in this code, but it's not being reported at the right place. In m.ts, there should be a duplicate identifier error:

// m.ts
import { Foo } from './s';
declare namespace Foo { };
                  ^^^
                  Duplicate identifier 'Foo'.

This is because imported identifiers don't merge with anything else.

@sandersn
Copy link
Member

sandersn commented Jun 1, 2016

@ahejlsberg pointed out offline that the compiler assumes that symbols are either aliases (imported/exported symbols) or local declarations -- never both. So as soon as export = Foo sees that Foo is locally declared, it exports only that. It never looks for the imported class Foo and never tries to merge them.

That means the code in m.ts is actually legal, but probably not what you wanted. Probably you want to use a module augmentation instead:

// s.ts
export class Foo {}

// m.ts
declare module './s' {
  namespace Foo { };
}
export var dummy = 1;

// c.ts
import { Foo } from './s'; // import from ./s instead of ./m
console.log(Foo);

@sandersn sandersn closed this as completed Jun 1, 2016
@sandersn sandersn added the Working as Intended The behavior described is the intended behavior; this is not a bug label Jun 1, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Jun 1, 2016

@sandersn there are cases where the error is not reported. but the export behavior is not what is expected. we should raise these as errors .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

3 participants