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

typescript@next (and 2.9.x) outputs node_modules relative path to imports #25345

Closed
felixknox opened this issue Jun 30, 2018 · 4 comments
Closed
Assignees
Labels
Bug A bug in TypeScript Needs More Info The issue still hasn't been fully clarified

Comments

@felixknox
Copy link

felixknox commented Jun 30, 2018

Related to issue #24599 , where @mhegazy specifically asks to create a separate ticket with more information when using latest typescript@next (^3.0.0-dev.20180630")

Imports get's node_modules added, which breaks Library conventions.

It's easy to replicate.
import ex. a library like @material-ui, which you have as a dependency.

Using a tsconfig file like

"compilerOptions": {
    "baseUrl": "./",
    "rootDir": "src",
    "outDir": "dist",

    "declaration": true,

    "module": "commonjs",
    "target": "es5",
    "lib": [ "es6", "dom" ],
    "sourceMap": true,
    "moduleResolution": "node",

    "jsx": "react",
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": false,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": false,
  },
  "exclude": [
    "node_modules"
  ]

Will take a .tsx file like:

import * as React from 'react';
import { WithStyles } from '@material-ui/core';
import { withStyles } from '@material-ui/core/styles';
import formBasicsStyles from "./../../../theme/formBasics";

interface IFileUploadProps extends WithStyles{

}

export const FileUpload = withStyles(formBasicsStyles)(
    class extends React.Component<IFileUploadProps> {
        constructor(props: IFileUploadProps){
            super(props);
        }

        public render() {
            const { classes } = this.props;

            return (
                <div>

                </div>
            );
        }
    }
);

And output a d.ts file like:

import * as React from 'react';
import { WithStyles } from '@material-ui/core';
interface IFileUploadProps extends WithStyles {
}
export declare const FileUpload: React.ComponentType<import("node_modules/@material-ui/core").Overwrite<IFileUploadProps, import("node_modules/@material-ui/core/styles/withStyles").StyledComponentProps<string>>>;
export {};

In the output d.ts file one would
expect: import("@material-ui....
but result is: import("node_modules/@material-ui...

Hope information is sufficient.

@felixknox felixknox changed the title typescript@next (and 2.9.x) outputs node_modules relate path to imports typescript@next (and 2.9.x) outputs node_modules relative path to imports Jun 30, 2018
@Kingwl
Copy link
Contributor

Kingwl commented Jul 1, 2018

#25186

@mhegazy
Copy link
Contributor

mhegazy commented Jul 2, 2018

looks like a possible duplicate of #25338

@mhegazy mhegazy added the Bug A bug in TypeScript label Jul 2, 2018
@mhegazy mhegazy added this to the TypeScript 3.0 milestone Jul 2, 2018
@weswigham
Copy link
Member

weswigham commented Jul 2, 2018

@mhegazy I'd wager it's much more likely another expression of #25186. (which @andy-ms has a fix open for)

@ghost
Copy link

ghost commented Jul 3, 2018

Should be fixed by #25364, please try again with typescript@next.

@ghost ghost added the Needs More Info The issue still hasn't been fully clarified label Jul 3, 2018
@mhegazy mhegazy closed this as completed Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

4 participants