Skip to content

The export type of namespace presents the wrong typing alert #37408

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
LenChang opened this issue Mar 16, 2020 · 4 comments
Closed

The export type of namespace presents the wrong typing alert #37408

LenChang opened this issue Mar 16, 2020 · 4 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@LenChang
Copy link

TypeScript Version: 3.7.2

Search Terms:
namespace, typing

Code

type Nullable<T> = T | null

export namespace ProfileFields {
   type name = string;
   type WHYYY = string | null;
   type id = string | null;
  // export type WHYYY = Nullable<string>;
  // export type id = Nullable<string>;
}

export interface Profile {
  name: ProfileFields.name;
  WHYYY: ProfileFields.WHYYY;
  id: ProfileFields.id;
}

export type General = Pick<Profile, 'WHYYY' | 'name' | 'id'>

Expected behavior:

type General = {
WHYYY: ProfileFields.WHHYY
name: ProfileFields.name
id: ProfileFields.id
}

Actual behavior:

type General = {
WHYYY: ProfileFields.WHHYY
name: ProfileFields.name
id: ProfileFields.WHHYY
}

Playground Link: Provided

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Mar 16, 2020
@RyanCavanaugh
Copy link
Member

Two type aliases for the same type are considered interchangeable (because they are), and declaration emit can choose arbitrarily between two equivalent types when finding a name to emit.

@LenChang
Copy link
Author

But it make me confused. I adjust the type of WHYYY & id to Nullable, and it make code more readable.

Has any better recommended method to use it ?

@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.

@RyanCavanaugh
Copy link
Member

#37444 should improve this

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