microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.26k stars 12.38k forks source link

jump to definition suggest file has nothing to do with my project #42273

Open craigcosmo opened 3 years ago

craigcosmo commented 3 years ago

Bug Report

🔎 Search Terms

jump to definition suggest file has nothing to do with my project

🕗 Version & Regression Information

Version: 1.52.1 Commit: ea3859d4ba2f3e577a159bc91e3074c5d85c0523 Date: 2020-12-16T16:30:02.420Z Electron: 9.3.5 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Darwin x64 20.2.0

⏯ Playground Link

none

💻 Code

import React, { useEffect } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import OrderTable from '../orderTable/OrderTable'
const Home = ({
    allData,
    userToken,
}) => {

    return (
        <React.Fragment>
            {userToken && <OrderTable allData={allData} />}
        </React.Fragment>
    )
}

function mapStateToProps(state) {
    return {
        allData: state.home.allData,
        userToken: state.auth.userToken,
    }
}
function mapDispatchToProps(dispatch) {
    return bindActionCreators({ getHomePageData, getProductName }, dispatch)
}
export default connect(mapStateToProps, mapDispatchToProps)(Home)
Screen Shot 2021-01-10 at 6 01 39 PM

🙁 Actual behavior

Jump to definition normally work like this, when I import a file or a module or a react component. press jump to definition will take me that file. But this case, vs code open 2 suggestion, suggesiton 1 is the file I want to go, suggestion 2 is the file has nothing to with my project, and it's not even within my project.

As you can see in the picture, I'm jumping to OrderTable component, Vscode suggestion OrderTable and some weird file in ~library/caches/typescript/4.1/node_modules.

🙂 Expected behavior

I want when I press jump to definition, I will be taken immediately directly to that file, instead seeing a suggestion of some totally unrelated files

Raynos commented 3 years ago

I've also run into this bug after updating to the latests vscode and its very very frustrating.