Typescript: Cannot redeclare block-scope variable

Created on 3 Mar 2017  路  6Comments  路  Source: microsoft/TypeScript

Seems pretty clear that I am not re-declaring the assert import - is there a way around this? Maybe just use import syntax instead?

screenshot 2017-03-02 17 56 09

Question

Most helpful comment

Just remove your declaration, write 'assert', and use Go To Definition. Or look at your error list; you will get a "Duplicate declaration" error on both declarations.

All 6 comments

I don't see that error when I try it.
Regardless, you should be using

import assert = require('assert');

If you are going to use require at all...

Not a TypeScript bug -- somewhere has assert defined and it's conflicting at a global level.

Please use Stack Overflow for questions.

@RyanCavanaugh sure in general I will happily ask questions on SO - though I doubt anyone on SO would be able to tell me why there is some global assert declaration somewhere....I am really confused about where/why such a global assert declaration would exist. Does TS report where the other declaration is.. and if not why not?

Shouldn't TS be able to know where the other (global) assert declaration is? I don't believe I have that info available in my editor.

Just remove your declaration, write 'assert', and use Go To Definition. Or look at your error list; you will get a "Duplicate declaration" error on both declarations.

@RyanCavanaugh @aluanhaddad is there some TS forum to ask questions besides SO? Like a Slack channel? I have one particular question that I can't get an answer for. I looked for a Slack channel and don't see anything. Thanks.

@ORESoftware not that I'm aware of. I understand that sometimes StackOverflow can be a little harsh but a number of people here answer questions on StackOverflow so why not just ask it there?

This issue is a good example of something that should be asked on StackOverflow. I'm pretty sure it could have been answered there.

Was this page helpful?
0 / 5 - 0 ratings