refactor: convert intersection type aliases to interfaces for better IDE tooltips#629
Open
refactor: convert intersection type aliases to interfaces for better IDE tooltips#629
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…r IDE tooltips Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rfaces Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…er types for nested intersections Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…aces Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…FoundContract Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e to interface Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Contributor
Unit Test Results - MidnightJS 20 files 58 suites 2m 38s ⏱️ Results for commit 5b495b0. |
Contributor
E2E Tests Resultse2e_tests_reports: Run #2966
🎉 All tests passed!Suites102 passed, 0 failed, and 8 other
Github Test Reporter by CTRF 💚 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Converts ~25 intersection type aliases (
type A = B & C) to interfaces (interface A extends B, C) across@midnight-ntwrk/midnight-js-contractsto improve IDE tooltip readability.Motivation
TypeScript handles
typealiases andinterfacedifferently when displaying tooltips in IDEs:typealiases using intersections are expanded inline, showing every constituent field recursively. For example, hovering overFinalizedCallTxData<C, PCK>would display a multi-line blob like:interfacewithextendsdisplays just the interface name:FinalizedCallTxData<C, PCK>This makes a significant difference for developer experience when working with the SDK, especially for types with deep inheritance chains like the transaction model types.
What changed
type A = { ... }) →interface A { ... }— 14 types acrossget-states.ts,call.ts,call-constructor.ts,tx-model.ts,find-deployed-contract.tstype A = B & C) →interface A extends B, C— 7 types acrosstx-model.ts,find-deployed-contract.ts,deploy-contract.ts,unproven-call-tx.tstx-model.tsfor nested property intersections (e.g., whereprivate: TypeA & TypeBneeded to become a named type)What was NOT changed
CallOptionsWithArguments,ContractConstructorOptionsWithArguments, etc.) — these useextends [] ? A : A & Bwhich cannot be expressed as interfacesFindDeployedContractOptions,CallOptions, etc.) — unions cannot be interfacesBenefits
Drawbacks
UnsubmittedDeployTxPrivateDataFull,FinalizedDeployTxPublicData,UnsubmittedCallTxPrivateData,FinalizedCallTxPublicData) — these are necessary to represent nested property intersections but increase the public API surfacetypealiases, creating an inconsistency in the codebase. However, this is a TypeScript language constraint, not a design choiceTest plan
yarn build --force --concurrency=1)yarn lint)yarn test— 21/21 tasks successful)🤖 Generated with Claude Code