Skip to content

Sibling namespace missing name from import in allowJs declaration #38834

Description

TypeScript Version: 4.0.0-dev.20200528

Search Terms: javascript declaration js dot array notation namespace

Code

index.js:

exportconstcolors={royalBlue: "#6400e4",};exportconstbrandColors={purple: colors.royalBlue,};

Expected behavior:

When compiled with tsc --allowJs --declaration --emitDeclarationOnly index.js, it should export:

exportnamespacecolors{exportconstroyalBlue: string;}exportnamespacebrandColors{importpurple=colors.royalBlue;export{purple};}

Actual behavior:

Instead, we get:

exportnamespacecolors{exportconstroyalBlue: string;}exportnamespacebrandColors{importpurple=royalBlue;export{purple};}

Note the import purple = royalBlue;. It's missing colors..

Compiler Options
{
"compilerOptions": {
"noImplicitAny": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"esModuleInterop": true,
"checkJs": true,
"allowJs": true,
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": 2,
"target": "ES2017",
"jsx": "React",
"module": "ESNext"
}
}

Playground Link:Provided

Related Issues: The closest issues I could find were #36270 and #33626...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions