Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Sibling namespace missing name from import in allowJs declaration #38834

Copy link
Copy link
@JoshuaKGoldberg

Description

@JoshuaKGoldberg
Issue body actions

TypeScript Version: 4.0.0-dev.20200528

Search Terms: javascript declaration js dot array notation namespace

Code

index.js:

export const colors = {
  royalBlue: "#6400e4",
};

export const brandColors = {
  purple: colors.royalBlue,
};

Expected behavior:

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

export namespace colors {
    export const royalBlue: string;
}
export namespace brandColors {
    import purple = colors.royalBlue;
    export { purple };
}

Actual behavior:

Instead, we get:

export namespace colors {
    export const royalBlue: string;
}
export namespace brandColors {
    import purple = 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...

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptA bug in TypeScript

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.