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

Same code got error in js file but no error in ts file #31312

Closed
yubaoquan opened this issue May 8, 2019 · 3 comments · Fixed by #32626
Closed

Same code got error in js file but no error in ts file #31312

yubaoquan opened this issue May 8, 2019 · 3 comments · Fixed by #32626
Assignees
Labels
Bug A bug in TypeScript checkJs Relates to checking JavaScript using TypeScript Fix Available A PR has been opened for this issue

Comments

@yubaoquan
Copy link

  • VSCode Version: 1.31.1
  • OS Version: win10 family

Steps to Reproduce:

test.js

import axios from 'axios' // Import declaration conflicts with local declaration of 'axios'.ts(2440)
axios.defaults.timeout = 22

In js file, the second line causes an error showing on first line.
But if this two lines are in ts file (change file suffix to ts), there is no error.

Does this issue occur when all extensions are disabled?: Yes

@vscodebot vscodebot bot assigned mjbvz May 8, 2019
@mjbvz mjbvz transferred this issue from microsoft/vscode May 8, 2019
@mjbvz
Copy link
Contributor

mjbvz commented May 8, 2019

Confirmed this on 3.5.0-dev.20190508.

From f12, the other local declaration of axios seems to be caused by the second line

@mjbvz mjbvz removed their assignment May 8, 2019
@weswigham weswigham added Bug A bug in TypeScript checkJs Relates to checking JavaScript using TypeScript labels May 8, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.6.0 milestone Jun 12, 2019
@orta
Copy link
Contributor

orta commented Jul 29, 2019

Looks like this happens with anything using import:

// example.js
import * as anything from 'typescript' // 1 import * as anything from 'typescript' // Import declaration  conflicts with local declaration of 'axios'.ts(2440)
         ~~~~~~~~~~~~~

anything.defaults.timeout = 22

// tsconfig
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "allowJs": true,
    "checkJs": true,
    "esModuleInterop": true
  }
}

@orta
Copy link
Contributor

orta commented Jul 30, 2019

Looks related to the binder: inside function checkAliasSymbol

symbol
// JS: __debugFlags:"Module|AliasExcludes|Assignment"
// TS: __debugFlags:"AliasExcludes"

TS has module and assignment stripped away somewhere, whereas JS does not which triggers the error message.

@orta orta added the Fix Available A PR has been opened for this issue label Jul 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript checkJs Relates to checking JavaScript using TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants