Skip to content

Fix declaration emit for symbol property keys from external modules#63110

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-declaration-file-imports
Draft

Fix declaration emit for symbol property keys from external modules#63110
Copilot wants to merge 4 commits intomainfrom
copilot/fix-declaration-file-imports

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

  • Understand the issue: Declaration emit uses symbol property keys without importing them
  • Create test case to reproduce the issue
  • Identify root cause: UniqueESSymbol property keys from external modules weren't being validated for value accessibility
  • Implement fix: Add accessibility check in getPropertyNameNodeForSymbolFromNameType and addPropertyToElementList
  • Update test baseline to reflect the fix (now generates TS4118 error instead of broken d.ts)
  • Verify existing tests still pass (uniqueSymbolPropertyDeclarationEmit)
  • Run linting and formatting
  • Run full test suite to check for regressions
  • Request code review
Original prompt

This section details on the original issue you should resolve

<issue_title>Declaration file emits symbol property keys without importing them</issue_title>
<issue_description>### 🔎 Search Terms

missing import in d.ts, symbol key not imported, unique symbol dts emit, dataTagSymbol not found, declaration file missing import

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about "Behavior That Looks Wrong (And Arguably Is) But Is Currently Working As Intended"
  • This bug is reproducible in the latest stable (5.9.2), and still occurs in next (6.0.0-dev.20250811)

⏯ Playground Link

https://stackblitz.com/edit/stackblitz-starters-vflvduch?file=src%2Findex.ts

💻 Code

Here's the code from the Stackblitz reproduction above.

src/index.ts:

import { fn } from 'test-pkg';
export const value = fn();

node_modules/test-pkg/index.d.ts:

declare const lostSymbol: unique symbol;
type lostSymbol = typeof lostSymbol;

type SomeGeneric<T> = {
    [lostSymbol]: T;
};

declare function fn(): SomeGeneric<unknown>;

export {
    lostSymbol,
    fn
};

🙁 Actual behavior

dist/index.d.ts:

export declare const value: {
    [lostSymbol]: unknown; // lostSymbol is not defined here and errors on the consumer's type check
};

🙂 Expected behavior

dist/index.d.ts:

import { lostSymbol } from 'test-pkg'; // should import from pacakge

export declare const value: {
    [lostSymbol]: unknown;
};

Additional information about the issue

Related?: #49065</issue_description>

Comments on the Issue (you are @copilot in this section)

@RyanCavanaugh I don't know why the bot did that 🤔

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone labels Feb 6, 2026
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix missing symbol property keys in declaration file Fix declaration emit for symbol property keys from external modules Feb 6, 2026
@DanielRosenwasser
Copy link
Member

@copilot keep at it

Copilot AI and others added 2 commits February 6, 2026 22:54
When a type uses a unique symbol from an external module as a property key,
check if the symbol is directly accessible as a value. If not, report
a non-serializable property error instead of silently emitting a broken
declaration file with an undefined reference.

Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Add accessibility check in getPropertyNameNodeForSymbolFromNameType to
detect when a unique symbol from an external module cannot be directly
accessed as a value. Reports a non-serializable property error to prevent
generating broken declaration files with undefined symbol references.

Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Declaration file emits symbol property keys without importing them

3 participants