Skip to content

chore(codegen): differentiate type imports#7897

Merged
kuhe merged 4 commits intomainfrom
kuhe/chore/imports-ordering
Mar 28, 2026
Merged

chore(codegen): differentiate type imports#7897
kuhe merged 4 commits intomainfrom
kuhe/chore/imports-ordering

Conversation

@kuhe
Copy link
Copy Markdown
Contributor

@kuhe kuhe commented Mar 27, 2026

Issue

codegen application for smithy-lang/smithy-typescript@3a71b57

Description

changes unnecessary runtime imports to type imports

Testing

CI, and this is covered by index tests (make test-indices).

Checklist

  • If the PR is a feature, add integration tests (*.integ.spec.ts) or E2E tests.
    • It's not a feature.
  • My E2E tests are resilient to concurrent i/o.
    • I didn't write any E2E tests.
  • I added access level annotations e.g. @public, @internal tags and enabled doc generation on the package. Remember that access level annotations go below the description, not above.
    • I didn't add any public functions.
  • Streams - how do they work?? My WebStream readers/locks are properly lifecycled. Node.js stream backpressure is handled. Error handling.
    • No streams here.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

UserAgent as __UserAgent,
} from "@smithy/types";
import { Readable } from "stream";
import type { Readable as Readable } from "node:stream";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is a workaround only affecting checksum clients

writer.addImport("type Readable", "Readable", "node:stream")

The addTypeImport API does not support arbitrary strings, since the string-based module import is deprecated (too easy to write an import of a module that isn't declared in the dependency list).

However, node packages don't need to be added to dependencies.

);
Map<String, HttpAuthSchemeParameter> httpAuthSchemeParameters =
AuthUtils.collectHttpAuthSchemeParameters(effectiveHttpAuthSchemes.values());
w.addDependency(TypeScriptDependency.SMITHY_TYPES);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

most addDependency calls can be removed because add[Type]Import when given a dependency object will automatically register it.

@kuhe kuhe force-pushed the kuhe/chore/imports-ordering branch from 00362fc to fad23f9 Compare March 27, 2026 15:46
@kuhe kuhe force-pushed the kuhe/chore/imports-ordering branch from fad23f9 to 1bfb2c5 Compare March 27, 2026 19:20
@kuhe kuhe marked this pull request as ready for review March 27, 2026 19:48
@kuhe kuhe requested a review from a team as a code owner March 27, 2026 19:48
@kuhe kuhe marked this pull request as draft March 27, 2026 20:05
@kuhe kuhe marked this pull request as ready for review March 27, 2026 20:07
@kuhe kuhe force-pushed the kuhe/chore/imports-ordering branch from 1bfb2c5 to dcacac8 Compare March 27, 2026 20:07
@kuhe kuhe merged commit 7f8c031 into main Mar 28, 2026
7 checks passed
@kuhe kuhe deleted the kuhe/chore/imports-ordering branch March 28, 2026 15:43
@github-actions
Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants