Skip to content

Typescript hover hints show wrong types #23747

Description

@mjbvz

From Nicolas Fernandez (@burabure) on April 26, 2018 22:28

Issue Type: Bug

I managed to confuse the ts language type hints, when you hover over the variables it shows a generic type, but forcing a type error on the same variable shows the correct type on the error.
This caused a couple hours of me looking over complex types trying to figure out why it showed me a variable as a generic one.

tsvscode

Here's the code that reproduces the error:

importReactfrom'react'interfaceIFooProps<S>{children: (state: S)=>JSX.ElementinitialState: S,}classFoo<Sextends{}>extendsReact.Component<IFooProps<S>,S>{state=this.props.initialStatepublicrender(){return<>{this.props.children(this.state)}</>}}interfaceIBarProps{test: 'hello',}constBar=(props: IBarProps)=>(<FooinitialState={props}>{(state)=><>{state.test}</>}</Foo>)

using these deps for example:

{
"typescript": "^2.8.1",
"react": "^16.3.1",
"@types/react": "^16.3.12",
}

VS Code version: Code 1.22.2 (3aeede733d9a3098f7b4bdc1f66b63b0f48c1ef9, 2018-04-12T16:34:44.222Z)
OS version: Linux x64 4.13.0-37-generic

System Info
ItemValue
CPUsIntel(R) Core(TM) i7-5600U CPU @ 2.60GHz (4 x 2593)
Load (avg)4, 4, 4
Memory (System)19.31GB (0.66GB free)
Process Argv/usr/share/code/code .
Screen Readerno
VM0%
Extensions (9)
ExtensionAuthor (truncated)Version
Bookmarksale0.19.0
npm-intellisensechr1.3.0
githistorydon0.4.0
tslinteg21.0.28
prettier-vscodeesb1.3.1
atom-keybindingsms-3.0.4
debugger-for-chromemsj4.3.0
snippet-creatornik0.0.4
code-spell-checkerstr1.6.9

(2 theme extensions excluded)

Copied from original issue: microsoft/vscode#48785

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions