Skip to content

Renaming a styled component does not always work from JSX #28065

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
mjbvz opened this issue Oct 22, 2018 · 2 comments
Closed

Renaming a styled component does not always work from JSX #28065

mjbvz opened this issue Oct 22, 2018 · 2 comments
Labels
Bug A bug in TypeScript Domain: JSX/TSX Relates to the JSX parser and emitter Fixed A PR has been merged for this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Oct 22, 2018

From @dontsave on October 22, 2018 20:40

  • VSCode Version: latest
  • OS Version: Windows 10

Renaming a styled component from the JSX does not rename the styled component at its declaration.

Steps to Reproduce:

test.tsx:

import styled from 'styled-components';
import * as React from 'react';

const Test = styled.div` <---- renaming Test here successfully renames test below
`;

export const Testing:React.SFC = p => {
	return (
		<div>
			<Test>hi there</Test> <----- renaming Test here does not rename test above
		</div>
	);
};

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

Copied from original issue: microsoft/vscode#61527

@mjbvz
Copy link
Contributor Author

mjbvz commented Oct 22, 2018

Tested with TS 3.2.0-dev-20181020

The rename response does not include the component definition:

Result: {
    "info": {
        "canRename": true,
        "displayName": "Test",
        "fullDisplayName": "Test",
        "kind": "const",
        "kindModifiers": "",
        "triggerSpan": {
            "start": {
                "line": 10,
                "offset": 14
            },
            "end": {
                "line": 10,
                "offset": 18
            }
        }
    },
    "locs": [
        {
            "file": "/Users/matb/projects/san/x.tsx",
            "locs": [
                {
                    "start": {
                        "line": 10,
                        "offset": 14
                    },
                    "end": {
                        "line": 10,
                        "offset": 18
                    }
                },
                {
                    "start": {
                        "line": 10,
                        "offset": 29
                    },
                    "end": {
                        "line": 10,
                        "offset": 33
                    }
                }
            ]
        }
    ]
}

@ghost ghost added the Bug A bug in TypeScript label Oct 22, 2018
@DanielRosenwasser DanielRosenwasser added the Domain: JSX/TSX Relates to the JSX parser and emitter label Oct 22, 2018
@ghost ghost added Fixed A PR has been merged for this issue and removed Domain: JSX/TSX Relates to the JSX parser and emitter labels Oct 22, 2018
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.2 milestone Oct 22, 2018
@ghost ghost added the Domain: JSX/TSX Relates to the JSX parser and emitter label Oct 22, 2018
@weswigham weswigham assigned ghost and unassigned weswigham Oct 22, 2018
@dontsave
Copy link

wow fast turnaround. i also noticed the original issue can be simplified to not include reference to styled components at all:

import * as React from 'react';

let S:React.ComponentClass; // <-- rename here changes both lines below

const e = <S/> // <-- rename here changes above
const e2 = <S></S> // <-- rename here does not change above

@ghost ghost closed this as completed in #28066 Oct 23, 2018
This issue was closed.
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: JSX/TSX Relates to the JSX parser and emitter Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants