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

Sibling namespace missing name from import in allowJs declaration #38834

Closed
JoshuaKGoldberg opened this issue May 28, 2020 · 1 comment
Closed
Assignees
Labels
Bug A bug in TypeScript

Comments

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented May 28, 2020

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

@weswigham
Copy link
Member

weswigham commented Jul 7, 2020

Looks like this is fixed in our latest nightlies. Probably by one of the refactors in #38982.

weswigham added a commit to weswigham/TypeScript that referenced this issue Jul 7, 2020
weswigham added a commit that referenced this issue Jul 8, 2020
cangSDARM added a commit to cangSDARM/TypeScript that referenced this issue Jul 9, 2020
* upstream/master: (75 commits)
  Insert auto-imports in sorted order (microsoft#39394)
  LEGO: check in for master to temporary branch.
  Better checking of @param/@Property tags (microsoft#39487)
  fix(25155): add space before optional parameters/properties (microsoft#38798)
  Add regression test for microsoft#38834 (microsoft#39479)
  Fixes searches for symbols exported using export * as (microsoft#39507)
  fix(39421): omit prefix text for rest binding element (microsoft#39433)
  fix(39440): show QF for abstract classes with methods which include 'this' parameter (microsoft#39465)
  Remove unnecessary assert (microsoft#39483)
  LEGO: check in for master to temporary branch.
  Update user baselines (microsoft#39220)
  Type `this` in more constructor functions (microsoft#39447)
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  Properly handle rest parameters in function declarations with @type annotations (microsoft#39473)
  Ensure type/namespaceish statics are included in the list of namespace merge members (microsoft#38920)
  Fix getTypeAtLocation for dotted implements clauses (microsoft#39363)
  Add workflow_dispatch to our nightly publish script. (microsoft#39485)
  Fix crash in decorator metadata calculation when serializing template literal type nodes (microsoft#39481)
  Fix test semantic merge conflict between microsoft#39348 and microsoft#39130 (microsoft#39478)
  ...

# Conflicts:
#	src/compiler/scanner.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants