Skip to content

fix: import elision for inline type specifiers, declare property decorators, and computed keys#10

Merged
Brooooooklyn merged 4 commits intomainfrom
02-04-fix_import_elision_specifier_mismatches
Feb 5, 2026
Merged

fix: import elision for inline type specifiers, declare property decorators, and computed keys#10
Brooooooklyn merged 4 commits intomainfrom
02-04-fix_import_elision_specifier_mismatches

Conversation

@Brooooooklyn
Copy link
Copy Markdown
Member

@Brooooooklyn Brooooooklyn commented Feb 4, 2026

Three import specifier mismatches fixed:

  1. Inline type specifiers (import { type FormGroup }) now tracked and elided
  2. declare property decorator args (@ViewChild(X) declare y) now elided
  3. Computed property keys in type annotations ([fromEmail]: T) now preserved

Note

Medium Risk
Medium risk: changes elision rules that directly affect emitted JS/TS imports, so mistakes could drop needed runtime imports or keep extra ones in Angular transforms.

Overview
Improves import elision accuracy in ImportElisionAnalyzer to match TypeScript/Angular behavior for several previously misclassified patterns.

Inline import { type X } specifiers are now always treated as elidable even when mixed with value imports, declare property decorators (and their arguments) are treated as compiler-only uses eligible for elision, and a new post-pass preserves imports referenced via computed property keys inside type annotations (e.g. { [fromEmail]: string }).

Adds regression tests covering these scenarios, including nested/union/array/tuple/parenthesized type shapes for computed keys.

Written by Cursor Bugbot for commit 3fc59c6. This will update automatically on new commits. Configure here.

…rators, and computed keys

Three import specifier mismatches fixed:
1. Inline `type` specifiers (`import { type FormGroup }`) now tracked and elided
2. `declare` property decorator args (`@ViewChild(X) declare y`) now elided
3. Computed property keys in type annotations (`[fromEmail]: T`) now preserved

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ction

The computed property key collector only checked the top-level members of
a TSTypeLiteral but did not recurse into property type annotations. This
meant nested patterns like `{ nested: { [fromEmail]: string } }` would
miss inner computed keys, incorrectly eliding those imports.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… types

The computed property key collector only handled TSTypeLiteral, TSUnionType,
and TSIntersectionType. Added support for TSArrayType, TSTupleType,
TSTypeReference (generics), and TSParenthesizedType so computed keys like
`[myKey]` inside these type structures are correctly preserved.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Adds explicit assertion that the decorator name itself (not just its
arguments) is correctly elided when only used on declare properties.
TypeScript does not emit declare properties, so the decorator has no
runtime effect.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Brooooooklyn Brooooooklyn merged commit 5627f7b into main Feb 5, 2026
3 checks passed
@Brooooooklyn Brooooooklyn deleted the 02-04-fix_import_elision_specifier_mismatches branch February 5, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant