Skip to content

TSX files doesn't suggest component properties #29017

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

Closed
nschurmann opened this issue Oct 1, 2018 · 3 comments
Closed

TSX files doesn't suggest component properties #29017

nschurmann opened this issue Oct 1, 2018 · 3 comments
Assignees
Labels
Bug A bug in TypeScript Domain: Completion Lists The issue relates to showing completion lists in an editor Domain: Contextual Types The issue relates to contextual types Domain: JSX/TSX Relates to the JSX parser and emitter Domain: Type Inference Related to type inference performed during signature resolution or `infer` type resolution Effort: Difficult Good luck.
Milestone

Comments

@nschurmann
Copy link

screen shot 2018-10-01 at 1 25 00 pm

This are the only props suggested in the autocomplete, @types for react router are installed, so it should suggest at least path and component.
@DanielRosenwasser DanielRosenwasser transferred this issue from microsoft/TypeScript-Sublime-Plugin Dec 14, 2018
@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Domain: JSX/TSX Relates to the JSX parser and emitter Domain: Completion Lists The issue relates to showing completion lists in an editor labels Dec 14, 2018
@DanielRosenwasser
Copy link
Member

Repro:

import * as React from "react";
import { Route } from "react-router"

class App extends React.Component {
	render() {
		return (
			<div>
				<Route path="" /*1*/ />
				<Route exact /*2*/ />
				<Route exact={true} /*3*/ />
			</div>
		);
	}
}

For the 3 markers, (1) has a completion that includes "" which is totally nonsensical, and all 3 exhibit the explained behavior.

image

@DanielRosenwasser DanielRosenwasser added Help Wanted You can do this Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". labels Dec 14, 2018
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.3 milestone Dec 14, 2018
@weswigham
Copy link
Member

weswigham commented Dec 20, 2018

Non-JSX repro of the same issue:

interface Foo {
    a?: number;
    b?: number;
}

function f<T extends Foo>(x: T) { }

f({/*1*/});

branch with a candidate fix (so I don't forget) is here. Currently it has some issues with the ThisType<T> tag that I need to investigate before opening a PR and seems to regress services behavior for

window.addEventListener("error", event/*1*/ => {
	event.filename;
});

but not

interface EventListenerWithOverloads {
	addEventListener(type: "error", listener: (this: Window, ev: ErrorEvent) => any, options?: boolean | AddEventListenerOptions): void;
	addEventListener(type: "beforeunload", listener: (this: Window, ev: BeforeUnloadEvent) => any, options?: boolean | AddEventListenerOptions): void;
}

declare var ev: EventListenerWithOverloads;

ev.addEventListener("error", event/*1*/ => {
	event.filename;
})

which I'll need to look into as well. (The first uses a mapped type and an index, while the second is overloads. It's possible the first won't work right without full generic inference, which is exactly what I'm trying to avoid because of the other issues it causes...)

I've long held that getContextualType needed to not be reentrant with inference, and with that branch, that is the case. The effect is that completions are a lot better (they come from the uninferred signatures now) and that literal types are retained in calls with errors and that an inferred boolean type can no longer contextual type itself. We've had a bunch of issues that essentially boil down to this same underlying flaw in contextual typing - I'll need to gather them all up along with their test cases.

@weswigham weswigham added Domain: Contextual Types The issue relates to contextual types Domain: Type Inference Related to type inference performed during signature resolution or `infer` type resolution Effort: Difficult Good luck. and removed Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this labels Jan 14, 2019
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Mar 14, 2019
@weswigham
Copy link
Member

This has been fixed since #36556 went in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Completion Lists The issue relates to showing completion lists in an editor Domain: Contextual Types The issue relates to contextual types Domain: JSX/TSX Relates to the JSX parser and emitter Domain: Type Inference Related to type inference performed during signature resolution or `infer` type resolution Effort: Difficult Good luck.
Projects
None yet
Development

No branches or pull requests

4 participants