Skip to content

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

Closed

Description

@yubaoquan
  • 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

Activity

  1. mjbvz commented on May 8, 2019

    @mjbvz

    Confirmed this on 3.5.0-dev.20190508.

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

  2. removed their assignment
    on May 8, 2019
  3. orta commented on Jul 29, 2019

    @orta
    Contributor

    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
      }
    }
  4. orta commented on Jul 30, 2019

    @orta
    Contributor

    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.

  5. added a commit that references this issue on Jul 30, 2019
    946a14f
  6. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issuecheckJsRelates to checking JavaScript using TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions