Skip to content

[codex] resolve dynamic import literal-union params#4287

Draft
andrewtdiz wants to merge 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-dynamic-import-param-union
Draft

[codex] resolve dynamic import literal-union params#4287
andrewtdiz wants to merge 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-dynamic-import-param-union

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Part of #1674.

Scope

  • Preserve inline TypeScript string literal type values in HIR as StringLiteral while keeping runtime/codegen treatment equivalent to String.
  • Collect function and closure parameters annotated with finite all-string-literal union types.
  • Feed those parameter candidate sets into dynamic import() and new Worker() path resolution alongside existing const/local resolution.
  • Add Node parity coverage for direct import(specifier) and template interpolation over a literal-union parameter.

Non-goals

  • Type alias expansion beyond what existing lowering already provides.
  • Mixed or broad string unions such as "./a.ts" | string.
  • Later assignment/reaching-definition analysis.
  • Package/bare wildcard imports or unbounded glob discovery.

Validation

  • npm exec --yes --package=node@26 -- node --experimental-strip-types test-parity/node-suite/module/loader/dynamic-import-param-union.ts
  • CARGO_TARGET_DIR=/tmp/perry-param-union-check cargo check -p perry-hir -p perry-codegen -p perry -p perry-runtime
  • CARGO_TARGET_DIR=/tmp/perry-param-union-check cargo test -p perry-hir dynamic_import -- --nocapture
  • CARGO_BUILD_JOBS=1 CARGO_TARGET_DIR=/root/perry-worktrees/.build-targets/perry-param-union-build cargo build --release -p perry -p perry-runtime -p perry-stdlib
  • Direct Perry compile/run of test-parity/node-suite/module/loader/dynamic-import-param-union.ts
  • PERRY_NO_AUTO_OPTIMIZE=1 CARGO_TARGET_DIR=/root/perry-worktrees/.build-targets/perry-param-union-build npm exec --yes --package=node@26 -- bash -lc './run_parity_tests.sh --suite node-suite --module module --filter dynamic-import-param-union'
  • PERRY_NO_AUTO_OPTIMIZE=1 CARGO_TARGET_DIR=/root/perry-worktrees/.build-targets/perry-param-union-build npm exec --yes --package=node@26 -- bash -lc './run_parity_tests.sh --suite node-suite --module module --filter dynamic-import'
  • cargo fmt --all -- --check
  • git diff --check
  • ./scripts/check_file_size.sh

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