Fix declaration emit for imported export alias specifiers#19852
Fix declaration emit for imported export alias specifiers#19852weswigham merged 3 commits intomicrosoft:masterfrom
Conversation
|
@weswigham does this address #8612 as well? |
|
@mhegazy Yes. Yes it does. Added repro. |
|
and #5938 probably |
|
Yup. We've had this bug for a long time, haven't we? |
|
yes we did. |
|
i guess i am to blame for that one 😊 |
|
Great work guys! Thanks! |
|
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) |
|
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. |
|
Please see Using Newer TypeScript Versions documentation for more details on updating your VSCode to use a different version of TypeScript. |
|
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. |
|
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;
`; |
|
OK, thanks. Unfortunately that approach doesn't work with Thanks for clarifying. |
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. 😄