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

Somtimes generating inline imports for d.ts files instead of using globally imported symbols #30258

Closed
CarstenLeue opened this issue Mar 7, 2019 · 2 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@CarstenLeue
Copy link

TypeScript Version: typescript@3.2.4
I cannot use a more recent version, since I am using the Angular build process that requires >=3.1.1 <3.3.

I am opening this issue as requested by defect
microsoft/rushstack#1067

The problem looks related to #25511 but that issue has been closed, still the problem persists for me.

Problem statement:

The d.ts file generated during my compile step looks like this:

export declare const authContentFeatureReducer: {
    [AUTH_CONTENT_FEATURE]: import("redux").Reducer<Record<string, import("@ibm-wch-sdk/api").AuthoringContentItem>, import("..").PayloadAction<string> | import("..").PayloadAction<import("@ibm-wch-sdk/api").AuthoringContentItem>>;
};

It references types from other modules via inline import statements. This causes a problem when generating documentation via the https://www.npmjs.com/package/@microsoft/api-documenter tool, because these inline import statements appear as is in the generated documentation. Instead of just the types they point to. This renders the documentation basically unreadable.

Expected behaviour
I would expect output similar to this:

import { Reducer } from 'redux';
import { AuthoringContentItem} from '@ibm-wch-sdk/api';
import { PayloadAction } from '..'

export declare const authContentFeatureReducer: {
    [AUTH_CONTENT_FEATURE]: Reducer<Record<string, AuthoringContentItem>, PayloadAction<string> | PayloadAction<AuthoringContentItem>>;
};

The actual source code looks like this:

import { authoringContentReducer } from './auth.content.reducer';

export const AUTH_CONTENT_FEATURE = 'authContent';

export const authContentFeatureReducer = {
  [AUTH_CONTENT_FEATURE]: authoringContentReducer
};
@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Mar 7, 2019
@RyanCavanaugh
Copy link
Member

We intentionally don't synthesize imports; writing an inline import is more predictable on our end and doesn't require any name collision logic.

If you add those imports to the file yourself, they'll be used, so I'd recommend doing that.

@typescript-bot
Copy link
Collaborator

This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

3 participants