Skip to content

Conversation

@mrgrain
Copy link
Contributor

@mrgrain mrgrain commented Dec 5, 2025

This PR adds support for aliased selective imports using an intuitive tuple syntax in the typewriter package.

Changes

  • Updated importSelective() to accept mixed arrays of strings and tuples: ['regular', ['name', 'alias']]
  • Added addAliasedImport() method for dynamic aliased imports
  • Introduced internal aliasMap to track name-to-alias mappings
  • Updated linkSymbol() to handle both regular and aliased imports
  • Modified TypeScript renderer to emit proper import { name as alias } syntax
  • Added comprehensive test coverage with inline snapshots
  • Added extensive JSDoc documentation with examples

Usage

// Mixed regular and aliased imports
source.importSelective(target, ['RegularImport', ['LongName', 'Short']]);
// Generates: import { RegularImport, LongName as Short } from "source";

// Avoiding name conflicts
reactModule.importSelective(myModule, [['Component', 'ReactComponent'], 'useState']);
// Generates: import { Component as ReactComponent, useState } from "react";

@mrgrain mrgrain force-pushed the mrgrain/feat/typewriter/aliased-selective-imports branch from 9cc3853 to 519286a Compare December 5, 2025 00:38
Enable aliased selective imports using tuple syntax: ['name', 'alias'].
The importSelective() method now accepts mixed arrays of strings and tuples,
generating 'import { name as alias }' syntax for tuple entries.
@mrgrain mrgrain force-pushed the mrgrain/feat/typewriter/aliased-selective-imports branch from 519286a to f4ccb82 Compare December 5, 2025 00:39
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

@aws-cdk/aws-service-spec: No model change detected

@mrgrain mrgrain changed the title feat(typewriter): add support for aliased selective imports feat(typewriter): support aliased imports with tuple syntax Dec 5, 2025
@mrgrain mrgrain force-pushed the mrgrain/feat/typewriter/aliased-selective-imports branch from 3269e29 to f4ccb82 Compare December 5, 2025 01:04
@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue Dec 5, 2025
Merged via the queue into main with commit ab6357a Dec 5, 2025
18 checks passed
@aws-cdk-automation aws-cdk-automation deleted the mrgrain/feat/typewriter/aliased-selective-imports branch December 5, 2025 06:28
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.

3 participants