Skip to content
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

Fix declaration emit for imported export alias specifiers #19852

Merged
merged 3 commits into from
Nov 9, 2017

Conversation

weswigham
Copy link
Member

@weswigham weswigham commented Nov 8, 2017

Fixes #19825
Fixes #8612
Fixes #5938

This was actually broken waaaaaay back in TS 1.6 by #3641; the real underlying issue which prompted that change has since been fixed by other changes, so all this line did was break things. 😄

@weswigham weswigham requested a review from mhegazy November 8, 2017 23:40
@mhegazy
Copy link
Contributor

mhegazy commented Nov 9, 2017

@weswigham does this address #8612 as well?

@weswigham
Copy link
Member Author

@mhegazy Yes. Yes it does. Added repro.

@mhegazy
Copy link
Contributor

mhegazy commented Nov 9, 2017

and #5938 probably

@weswigham
Copy link
Member Author

Yup. We've had this bug for a long time, haven't we?

@mhegazy
Copy link
Contributor

mhegazy commented Nov 9, 2017

yes we did.

@mhegazy
Copy link
Contributor

mhegazy commented Nov 9, 2017

i guess i am to blame for that one 😊

@weswigham weswigham merged commit ceaeffa into microsoft:master Nov 9, 2017
@weswigham weswigham deleted the fix-symbols branch November 9, 2017 02:44
@loucyx
Copy link

loucyx commented Nov 9, 2017

Great work guys! Thanks!

@jacobbogers
Copy link

Great, if i install tsc in the project, not globally, the newest it will compile; but vscode editor still marks it as an error, maybe unrelated but its not picking up the new tsc? (globally de-installed tsc, so its only using the tsc of the project, me thinks)

@weswigham
Copy link
Member Author

vscode has a copy of TS bundled with it. There's a workspace setting you can use to tell it to use the workspace certain instead.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 2, 2017

Please see Using Newer TypeScript Versions documentation for more details on updating your VSCode to use a different version of TypeScript.

@jamiewinder
Copy link

I was hoping this was meant to fix a long-time bugbear of mine; I cannot using declarations with modules that export styled-component components.

For example, this very basic, very common scenario:

import styled from "styled-components";

export const Test = styled.div`
    color: black;
`;

i.e. just exporting a styled component, won't work because:

[ts] Exported variable 'Test' has or is using name 'React.ClassAttributes' from external module "node_modules/@types/react/index" but cannot be named.
[ts] Exported variable 'Test' has or is using name 'React.HTMLAttributes' from external module "node_modules/@types/react/index" but cannot be named.
[ts] Exported variable 'Test' has or is using name 'StyledComponentClass' from external module "node_modules/styled-components/typings/styled-components" but cannot be named.

Was this meant to fix this scenario? Because with 2.7.0-dev.20180103 I still get the same.

@weswigham
Copy link
Member Author

No, that'd be related to #9944. For now you should be adding imports/references to the files whose types you need to use in your own declaration output, for now. For example,

import {StyledComponentClass}, styled from "styled-components";
import * as React from "react";

export const Test = styled.div`
    color: black;
`;

@jamiewinder
Copy link

jamiewinder commented Jan 4, 2018

OK, thanks. Unfortunately that approach doesn't work with --noUnusedLocals as you have to refer to the import at least once to suppress the warning (which can force in somewhere, but it's messy).

Thanks for clarifying.

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants