Repository navigation
Conversation
… classes
Message types from SDK declarations often use shapes scriptc refused:
- `{ [key: string]: any }` and `Dictionary<any>` (also a bare
`Dictionary<T = any>`): the overflow values are checked-dynamic, like
`Record<string, unknown>`'s.
- `any[]` members an interface, type literal or class declares, also
optional or nullable: the checked-dynamic array, as `unknown[]` maps.
An object literal's inferred `any[]` member keeps its existing story.
- A class a types-only package declares with public fields only (aws-sdk's
`declare class PresignedPost { url: string; fields: Fields }`, with a
merged namespace of types): it describes JSON data and is never
constructed, so it maps structurally like an interface.
- `Pick<C, K>` and `Omit<C, K>` over a program class, when the view exposes
a method: like an interface the class matches, it keeps a live receiver,
so calls through the view run on the instance.
A record blocked by a member deep inside it now names that member's path
(`member 'poll().jobs[].handle' has type ...`) instead of the outermost
member only; a member holding `any` is named itself.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| (declaration) => | ||
| ts.isInterfaceDeclaration(declaration) && | ||
| !declaration.getSourceFile().isDeclarationFile, | ||
| )) |
Contributor
…ther structural type A Pick or Omit view of a program class that holds the instance (its view exposes a method) now carries the class's identity in the flow analysis, and its values count as instances of that class. Assigning such a view to another structural type keeps the instance, so reads through the second type see the instance's later writes instead of a copy's.
…Pick views
- A call that resolves to an overload signature of a generic function or
method with an implementation (`load<T>(k, map: Mapper<T>): Promise<T>;
load(k): Promise<Reply>; load<T>(k, map?) {...}`) monomorphizes the
implementation under the bindings the overload's resolved signature
proves; a type parameter the overload never mentions is unknown, and
parameters the overload omits must be optional in the implementation.
It was refused.
- `view.m(...)` where `view` is a `Pick`/`Omit` view of a program class
and `m` is a generic (or generically overloaded) method extracts the
instance from the view's live receiver and calls the method statically,
instead of a runtime refusal reading the method through the untyped
view.
- Binding inference pairs the arms of `T | Promise<T>` with an
instantiated `R | Promise<R>`, and `unknown | Promise<unknown>` maps to
the checked-dynamic value the checker reduces it to.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment on lines
+410
to
+420
| (_param, i) => expr.arguments.nodes[i] ?? expr, | ||
| ); | ||
| returnType = lowerer.mapTypeOf(lowerer.checker.getReturnTypeOfSignature(declSig)); | ||
| } finally { | ||
| lowerer.typeParamBindings = previous; | ||
| lowerer.typeParamTsBindings = previousTs; | ||
| } | ||
| if (!returnType) return null; | ||
| // keyof-constrained parameters key their instance on the bound literal, | ||
| // as on the implementation-signature path. | ||
| return internGenericInstance(lowerer, expr, info, params, returnType, () => bindings, { |
Contributor
This branch was successfully deployed
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.
Service code often types its messages with declarations from SDKs and shared type packages. Several of those shapes were refused, and since a message type usually reaches a provider interface, one refused member blocked every function that handled the message. The diagnostic also named only the outermost member, so finding the offending one inside a 40-member record meant bisecting by hand.
any-valued dictionariesAn index signature whose value type is
anynow holds checked-dynamic values, exactly asRecord<string, unknown>does. This includes a generic dictionary alias used without a type argument.any[]membersA record member that an interface, type literal or class declares as
any[], also optional or nullable, is the checked-dynamic array, asunknown[]already maps. An object literal's inferredany[]member and all otherany[]positions keep their existing rules, so programs that already compiled build the same code.Data classes declared by types-only packages
A class that a package's declaration file declares with public instance fields only (no constructor, methods, accessors, index signatures, static, private or protected members, base classes or type parameters), optionally merged with a namespace of types, describes data. It now maps structurally, like an interface, so values from
JSON.parseor object literals compile as records. Its class value, which has no implementation, stays refused.PickandOmitviews of a classPick<C, K>andOmit<C, K>over a program class, when the view exposes a method, are treated like an interface the class matches: values keep a live receiver, so calls through the view run on the instance and share its state. Field-only views keep their record representation.Nested member paths in record diagnostics
The record-member diagnostic now follows the failure through function results (
()), promise payloads and union arms, record members (.name) and array elements ([]) down to the member it comes from. A member that holdsanyis named itself.Not included
Function types with
anyparameters ((reason?: any) => void) are handled by #1433.Evidence
6412-any-valued-dictionaries.ts,6413-sdk-declared-data-class(a types-only package) and6414-pick-class-method-views.ts. All three match Node byte for byte in the plain and sanitized lanes.nested-member-blocker-path.ts. Existing snapshots are unchanged, because a path stops at the member that holds anany.diagnostics.test.ts: 200/200.any[]member; that is why theany[]rule is limited to declared members. The self-hosted compiler IR build exits 0 with no diagnostics. Frontend and IR unit tests: 1243/1243.pnpm lintandpnpm format:checkare clean, andpnpm test:ts7 --baselines-onlypasses, with 4 new baselines and no existing ones changed.🤖 Generated with Claude Code