Skip to content

Typescript compilation emit a new import with a wrong path while the type is already imported before #27136

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
pradel opened this issue Sep 17, 2018 · 3 comments

Comments

@pradel
Copy link

pradel commented Sep 17, 2018

Description

Typescript compilation emit a new import for an inferred type with a wrong path while the type is already imported before at the top of the file.

TypeScript Version: 3.0.3

Search Terms:

  • declaration path

Code

import { emailTemplates } from './utils/email';

const defaultOptions = {
  tokenSecret: 'secret',
  tokenConfigs: {
    accessToken: {
      expiresIn: '90m',
    },
    refreshToken: {
      expiresIn: '7d',
    },
  },
  // Type is inferred here
  emailTemplates,
  userObjectSanitizer: (user: User) => user,
  sendMail,
  siteUrl: 'http://localhost:3000',
};

Expected behavior:

// ...
import { EmailTemplateType } from './types/email-template-type';
declare const defaultOptions: {
    tokenSecret: string;
    tokenConfigs: {
        accessToken: {
            expiresIn: string;
        };
        refreshToken: {
            expiresIn: string;
        };
    };
    emailTemplates: EmailTemplateType;
    userObjectSanitizer: (user: User) => User;
    sendMail: (mail: object) => Promise<void>;
    siteUrl: string;
};
// ...

Actual behavior:

// ...
import { EmailTemplateType } from './types/email-template-type';
declare const defaultOptions: {
    tokenSecret: string;
    tokenConfigs: {
        accessToken: {
            expiresIn: string;
        };
        refreshToken: {
            expiresIn: string;
        };
    };
    emailTemplates: import("@accounts/server/src/types/email-templates-type").EmailTemplatesType;
    userObjectSanitizer: (user: User) => User;
    sendMail: (mail: object) => Promise<void>;
    siteUrl: string;
};
// ...

How to reproduce:

Happy to provide more infos if needed thanks :)

@ghost
Copy link

ghost commented Sep 18, 2018

Looks like compiling your repro with typescript@next is currently blocked by #26978.

@pradel
Copy link
Author

pradel commented Sep 18, 2018

@Andy-MS yeah you are right I have this error when I try with the next tag

@pradel
Copy link
Author

pradel commented Sep 21, 2018

Looks like the error was fixed in 3.1.0-dev.20180921 thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant