diff --git a/types/discord-rpc/package.json b/types/discord-rpc/package.json index 5de02188720327..f6d1ed6b23c790 100644 --- a/types/discord-rpc/package.json +++ b/types/discord-rpc/package.json @@ -12,6 +12,10 @@ "@types/discord-rpc": "workspace:." }, "owners": [ + { + "name": "Brandon Bothell", + "githubUsername": "brandonbothell" + }, { "name": "Dylan Hackworth", "githubUsername": "dylhack" diff --git a/types/fhir/r2.d.ts b/types/fhir/r2.d.ts index a1880c8d2cde28..0153485adfc265 100644 --- a/types/fhir/r2.d.ts +++ b/types/fhir/r2.d.ts @@ -12038,7 +12038,7 @@ export interface HumanName extends Element { /** * Base StructureDefinition for Bundle Resource */ -export interface Bundle extends Resource { +export interface Bundle extends Resource { /** Resource Type Name (for serialization) */ readonly resourceType: 'Bundle'; /** @@ -12062,7 +12062,7 @@ export interface Bundle extends Resource { * Entry in the bundle - will have a resource, or information * An entry in a bundle resource - will either contain a resource, or information about a resource (transactions and history only). */ - entry?: BundleEntry[] | undefined; + entry?: BundleEntry[] | undefined; /** * Digital Signature * Digital Signature - base64 encoded. XML DigSIg or a JWT. @@ -12186,7 +12186,7 @@ export interface BundleEntryResponse extends BackboneElement { * Entry in the bundle - will have a resource, or information * An entry in a bundle resource - will either contain a resource, or information about a resource (transactions and history only). */ -export interface BundleEntry extends BackboneElement { +export interface BundleEntry extends BackboneElement { /** * Absolute URL for resource (server address, or UUID/OID) * The Absolute URL for the resource. This must be provided for all resources. The fullUrl SHALL not disagree with the id in the resource. The fullUrl is a version independent reference to the resource. @@ -12197,7 +12197,7 @@ export interface BundleEntry extends BackboneElement { * A resource in the bundle * The Resources for the entry. */ - resource?: Resource | undefined; + resource?: T | undefined; /** * Search related information * Information about the search process that lead to the creation of this entry. diff --git a/types/fhir/r3.d.ts b/types/fhir/r3.d.ts index 4ed56f38d30633..2baf2fd4d4124a 100644 --- a/types/fhir/r3.d.ts +++ b/types/fhir/r3.d.ts @@ -18821,7 +18821,7 @@ export interface HumanName extends Element { /** * Base StructureDefinition for Bundle Resource */ -export interface Bundle extends Resource { +export interface Bundle extends Resource { /** Resource Type Name (for serialization) */ readonly resourceType: 'Bundle'; /** @@ -18853,7 +18853,7 @@ export interface Bundle extends Resource { * Entry in the bundle - will have a resource, or information * An entry in a bundle resource - will either contain a resource, or information about a resource (transactions and history only). */ - entry?: BundleEntry[] | undefined; + entry?: BundleEntry[] | undefined; /** * Digital Signature * Digital Signature - base64 encoded. XML-DSIg or a JWT. @@ -18989,7 +18989,7 @@ export interface BundleEntryResponse extends BackboneElement { * Entry in the bundle - will have a resource, or information * An entry in a bundle resource - will either contain a resource, or information about a resource (transactions and history only). */ -export interface BundleEntry extends BackboneElement { +export interface BundleEntry extends BackboneElement { /** * Links related to this entry * A series of links that provide context to this entry. @@ -19008,7 +19008,7 @@ export interface BundleEntry extends BackboneElement { * A resource in the bundle * The Resources for the entry. */ - resource?: Resource | undefined; + resource?: T | undefined; /** * Search related information * Information about the search process that lead to the creation of this entry. diff --git a/types/fhir/r4.d.ts b/types/fhir/r4.d.ts index 948f605def022e..62ca98c79934d6 100644 --- a/types/fhir/r4.d.ts +++ b/types/fhir/r4.d.ts @@ -25659,7 +25659,7 @@ export interface EvidenceVariableCharacteristic extends BackboneElement { /** * A container for a collection of resources. */ -export interface Bundle extends Resource { +export interface Bundle extends Resource { /** Resource Type Name (for serialization) */ readonly resourceType: 'Bundle'; /** @@ -25708,7 +25708,7 @@ export interface Bundle extends Resource { * Entry in the bundle - will have a resource or information * An entry in a bundle resource - will either contain a resource or information about a resource (transactions and history only). */ - entry?: BundleEntry[] | undefined; + entry?: BundleEntry[] | undefined; /** * Digital Signature * Digital Signature - base64 encoded. XML-DSig or a JWT. @@ -25849,7 +25849,7 @@ export interface BundleEntryResponse extends BackboneElement { * Entry in the bundle - will have a resource or information * An entry in a bundle resource - will either contain a resource or information about a resource (transactions and history only). */ -export interface BundleEntry extends BackboneElement { +export interface BundleEntry extends BackboneElement { /** * Links related to this entry * A series of links that provide context to this entry. @@ -25869,7 +25869,7 @@ export interface BundleEntry extends BackboneElement { * A resource in the bundle * The Resource for the entry. The purpose/meaning of the resource is determined by the Bundle.type. */ - resource?: Resource | undefined; + resource?: T | undefined; /** * Search related information * Information about the search process that lead to the creation of this entry. diff --git a/types/fhir/r4b.d.ts b/types/fhir/r4b.d.ts index 380bb21057cd25..79a88e9ba1580d 100644 --- a/types/fhir/r4b.d.ts +++ b/types/fhir/r4b.d.ts @@ -26035,7 +26035,7 @@ export interface CodeableReference extends Element { /** * A container for a collection of resources. */ -export interface Bundle extends Resource { +export interface Bundle extends Resource { /** Resource Type Name (for serialization) */ readonly resourceType: 'Bundle'; /** @@ -26084,7 +26084,7 @@ export interface Bundle extends Resource { * Entry in the bundle - will have a resource or information * An entry in a bundle resource - will either contain a resource or information about a resource (transactions and history only). */ - entry?: BundleEntry[] | undefined; + entry?: BundleEntry[] | undefined; /** * Digital Signature * Digital Signature - base64 encoded. XML-DSig or a JWT. @@ -26225,7 +26225,7 @@ export interface BundleEntryResponse extends BackboneElement { * Entry in the bundle - will have a resource or information * An entry in a bundle resource - will either contain a resource or information about a resource (transactions and history only). */ -export interface BundleEntry extends BackboneElement { +export interface BundleEntry extends BackboneElement { /** * Links related to this entry * A series of links that provide context to this entry. @@ -26245,7 +26245,7 @@ export interface BundleEntry extends BackboneElement { * A resource in the bundle * The Resource for the entry. The purpose/meaning of the resource is determined by the Bundle.type. */ - resource?: Resource | undefined; + resource?: T | undefined; /** * Search related information * Information about the search process that lead to the creation of this entry. diff --git a/types/fhir/r5.d.ts b/types/fhir/r5.d.ts index c67d6c32a4d190..70285b7d70b1f4 100644 --- a/types/fhir/r5.d.ts +++ b/types/fhir/r5.d.ts @@ -32200,7 +32200,7 @@ export interface CodeableReference extends DataType { /** * A container for a collection of resources. */ -export interface Bundle extends Resource { +export interface Bundle extends Resource { /** Resource Type Name (for serialization) */ readonly resourceType: 'Bundle'; /** @@ -32249,7 +32249,7 @@ export interface Bundle extends Resource { * Entry in the bundle - will have a resource or information * An entry in a bundle resource - will either contain a resource or information about a resource (transactions and history only). */ - entry?: BundleEntry[] | undefined; + entry?: BundleEntry[] | undefined; /** * Digital Signature * Digital Signature - base64 encoded. XML-DSig or a JWS. @@ -32396,7 +32396,7 @@ export interface BundleEntryResponse extends BackboneElement { * Entry in the bundle - will have a resource or information * An entry in a bundle resource - will either contain a resource or information about a resource (transactions and history only). */ -export interface BundleEntry extends BackboneElement { +export interface BundleEntry extends BackboneElement { /** * Links related to this entry * A series of links that provide context to this entry. @@ -32417,7 +32417,7 @@ export interface BundleEntry extends BackboneElement { * A resource in the bundle * The Resource for the entry. The purpose/meaning of the resource is determined by the Bundle.type. This is allowed to be a Parameters resource if and only if it is referenced by something else within the Bundle that provides context/meaning. */ - resource?: Resource | undefined; + resource?: T | undefined; /** * Search related information * Information about the search process that lead to the creation of this entry. diff --git a/types/fhir/test/r2-tests.ts b/types/fhir/test/r2-tests.ts index 8fddf158baf8fc..9347efca9727d4 100644 --- a/types/fhir/test/r2-tests.ts +++ b/types/fhir/test/r2-tests.ts @@ -316,3 +316,17 @@ const r2Bundle: fhir2.Bundle = { const r2HasPatient = r2Bundle.entry?.some( (e) => e.resource?.resourceType === "Patient", ); + +// 6. Bundle and BundleEntry generic typing +// Regression for https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/75098 +const r2PatientBundle: fhir2.Bundle = { + resourceType: "Bundle", + type: "collection", + entry: [{ resource: r2InlinePatient }], +}; +const r2PatientEntry = r2PatientBundle.entry?.[0]; +// patientEntry resource should be typed as Patient | undefined +if (r2PatientEntry?.resource?.resourceType === "Patient") { + // Access a Patient-specific field (e.g. id) to prove narrow typing + const r2PtId: string | undefined = r2PatientEntry.resource.id; +} diff --git a/types/fhir/test/r3-tests.ts b/types/fhir/test/r3-tests.ts index 078cb2d236ac03..3775fd655a3b7d 100644 --- a/types/fhir/test/r3-tests.ts +++ b/types/fhir/test/r3-tests.ts @@ -388,3 +388,17 @@ const r3Bundle: fhir3.Bundle = { const r3HasPatient = r3Bundle.entry?.some( (e) => e.resource?.resourceType === "Patient", ); + +// 6. Bundle and BundleEntry generic typing +// Regression for https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/75098 +const r3PatientBundle: fhir3.Bundle = { + resourceType: "Bundle", + type: "collection", + entry: [{ resource: r3InlinePatient }], +}; +const r3PatientEntry = r3PatientBundle.entry?.[0]; +// patientEntry resource should be typed as Patient | undefined +if (r3PatientEntry?.resource?.resourceType === "Patient") { + // Access a Patient-specific field (e.g. id) to prove narrow typing + const r3PtId: string | undefined = r3PatientEntry.resource.id; +} diff --git a/types/fhir/test/r4-tests.ts b/types/fhir/test/r4-tests.ts index 5a89dba1231d73..0ccd17c5a31624 100644 --- a/types/fhir/test/r4-tests.ts +++ b/types/fhir/test/r4-tests.ts @@ -460,3 +460,17 @@ const r4Bundle: fhir4.Bundle = { const r4HasPatient = r4Bundle.entry?.some( (e) => e.resource?.resourceType === "Patient", ); + +// 6. Bundle and BundleEntry generic typing +// Regression for https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/75098 +const r4PatientBundle: fhir4.Bundle = { + resourceType: "Bundle", + type: "collection", + entry: [{ resource: r4InlinePatient }], +}; +const r4PatientEntry = r4PatientBundle.entry?.[0]; +// patientEntry resource should be typed as Patient | undefined +if (r4PatientEntry?.resource?.resourceType === "Patient") { + // Access a Patient-specific field (e.g. id) to prove narrow typing + const r4PtId: string | undefined = r4PatientEntry.resource.id; +} diff --git a/types/fhir/test/r4b-tests.ts b/types/fhir/test/r4b-tests.ts index 16ae3605f38e03..b581de50c5570c 100644 --- a/types/fhir/test/r4b-tests.ts +++ b/types/fhir/test/r4b-tests.ts @@ -454,3 +454,17 @@ const r4bBundle: fhir4b.Bundle = { const r4bHasPatient = r4bBundle.entry?.some( (e) => e.resource?.resourceType === "Patient", ); + +// 6. Bundle and BundleEntry generic typing +// Regression for https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/75098 +const r4bPatientBundle: fhir4b.Bundle = { + resourceType: "Bundle", + type: "collection", + entry: [{ resource: r4bInlinePatient }], +}; +const r4bPatientEntry = r4bPatientBundle.entry?.[0]; +// patientEntry resource should be typed as Patient | undefined +if (r4bPatientEntry?.resource?.resourceType === "Patient") { + // Access a Patient-specific field (e.g. id) to prove narrow typing + const r4bPtId: string | undefined = r4bPatientEntry.resource.id; +} diff --git a/types/fhir/test/r5-tests.ts b/types/fhir/test/r5-tests.ts index fd055823deb713..b9cbac3399ef9d 100644 --- a/types/fhir/test/r5-tests.ts +++ b/types/fhir/test/r5-tests.ts @@ -499,3 +499,17 @@ const r5Bundle: fhir5.Bundle = { const r5HasPatient = r5Bundle.entry?.some( (e) => e.resource?.resourceType === "Patient", ); + +// 6. Bundle and BundleEntry generic typing +// Regression for https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/75098 +const r5PatientBundle: fhir5.Bundle = { + resourceType: "Bundle", + type: "collection", + entry: [{ resource: r5InlinePatient }], +}; +const r5PatientEntry = r5PatientBundle.entry?.[0]; +// patientEntry resource should be typed as Patient | undefined +if (r5PatientEntry?.resource?.resourceType === "Patient") { + // Access a Patient-specific field (e.g. id) to prove narrow typing + const r5PtId: string | undefined = r5PatientEntry.resource.id; +} diff --git a/types/frida-gum/frida-gum-tests.ts b/types/frida-gum/frida-gum-tests.ts index 89ca1c02233df6..e45799b9daf9a4 100644 --- a/types/frida-gum/frida-gum-tests.ts +++ b/types/frida-gum/frida-gum-tests.ts @@ -192,6 +192,39 @@ Process.mainModule; // $ExpectType string | null Process.mainModule.version; +// $ExpectType MemoryRange | null +Process.findFunctionRange(Process.mainModule.base); + +const cfg = new ControlFlowGraph(Process.mainModule.base); +// $ExpectType NativePointer +cfg.entrypoint; +// $ExpectType BasicBlock +const entryBlock = cfg.entryBlock; +// $ExpectType BasicBlock[] +cfg.blocks; +// $ExpectType BasicBlock | null +cfg.findBlockContaining(Process.mainModule.base); +// $ExpectType boolean +cfg.dominates(Process.mainModule.base, Process.mainModule.base); +// $ExpectType DominatingSite[] +const sites = cfg.enumerateDominatingSites(Process.mainModule.base); +// $ExpectType NativePointer +sites[0].address; +// $ExpectType number +sites[0].capacity; +// $ExpectType NativePointer +entryBlock.start; +// $ExpectType NativePointer +entryBlock.end; +// $ExpectType BasicBlock[] +entryBlock.successors; +// $ExpectType BasicBlock[] +entryBlock.predecessors; +// $ExpectType BasicBlock | null +entryBlock.immediateDominator; +// $ExpectType Instruction[] +entryBlock.instructions; + const art = Process.getModuleByName("libart.so"); // $ExpectType NativePointer art.getSymbolByName("ExecuteNterpImpl"); diff --git a/types/frida-gum/index.d.ts b/types/frida-gum/index.d.ts index ffd8307952ec4b..1471148051509b 100644 --- a/types/frida-gum/index.d.ts +++ b/types/frida-gum/index.d.ts @@ -438,6 +438,17 @@ declare namespace Process { */ function getRangeByAddress(address: NativePointerValue): RangeDetails; + /** + * Determines the code range of the function that `address` belongs to, + * derived from the platform's unwind tables. A function whose body is split + * across several ranges (e.g. a cold fragment) is represented by one range + * per fragment; this returns the one covering `address`. Where no unwind + * information is available — e.g. a leaf function, or a target lacking + * unwind tables altogether — the containing symbol's bounds are used as a + * best-effort fallback. Returns null if neither yields a range. + */ + function findFunctionRange(address: NativePointerValue): MemoryRange | null; + /** * Enumerates memory ranges satisfying `specifier`. * @@ -4321,6 +4332,121 @@ declare class Instruction { toString(): string; } +/** + * Control-flow graph of a single function, with its basic blocks, edges, and + * dominator relationships. + */ +declare class ControlFlowGraph { + /** + * Builds the control-flow graph of the function containing `entrypoint`. + * + * The function's bounds are resolved the same way as + * `Process.findFunctionRange()` — from the platform's unwind tables, with + * the containing symbol's bounds as a best-effort fallback — and its + * architecture and mode are determined automatically. On 32-bit ARM, a + * least significant bit set to 1 indicates Thumb. + * + * Throws an exception if the bounds of the function cannot be determined. + * + * @param entrypoint Address of the function to analyze. + */ + constructor(entrypoint: NativePointerValue); + + /** + * Address that the graph was built from. + */ + entrypoint: NativePointer; + + /** + * Basic block that the function begins with. + */ + entryBlock: BasicBlock; + + /** + * All basic blocks making up the graph. + */ + blocks: BasicBlock[]; + + /** + * Looks up the basic block containing `address`. Returns null if no block + * covers it. + * + * @param address Address to look up. + */ + findBlockContaining(address: NativePointerValue): BasicBlock | null; + + /** + * Determines whether the block containing `a` dominates the block + * containing `b`, i.e. whether every path from the entry block to `b` + * passes through `a`. + * + * @param a Address whose block is the potential dominator. + * @param b Address whose block is potentially dominated. + */ + dominates(a: NativePointerValue, b: NativePointerValue): boolean; + + /** + * Enumerates the sites that dominate `target`, nearest first. + * + * @param target Address to find the dominating sites of. + */ + enumerateDominatingSites(target: NativePointerValue): DominatingSite[]; +} + +/** + * A basic block within a `ControlFlowGraph`. Not constructable; obtain + * instances through the graph. + */ +declare class BasicBlock { + /** + * Address of the first instruction in the block. + */ + start: NativePointer; + + /** + * Address just past the last instruction in the block. + */ + end: NativePointer; + + /** + * Blocks that control may flow to from this block. + */ + successors: BasicBlock[]; + + /** + * Blocks that control may flow to this block from. + */ + predecessors: BasicBlock[]; + + /** + * Block that immediately dominates this one, or null for the entry block. + */ + immediateDominator: BasicBlock | null; + + /** + * Instructions making up this block. + */ + instructions: Instruction[]; +} + +/** + * A site that dominates a given target, as returned by + * `ControlFlowGraph#enumerateDominatingSites()`. + */ +interface DominatingSite { + /** + * Instruction-aligned address that dominates the target. + */ + address: NativePointer; + + /** + * Number of contiguous bytes at `address`, within a single range and with + * no incoming branch, that a redirect may overwrite without another + * control-flow edge landing inside the patched region. + */ + capacity: number; +} + declare class X86Instruction extends Instruction { /** * Array of objects describing each operand. diff --git a/types/frida-gum/package.json b/types/frida-gum/package.json index 4da2f137d7e5d9..996732febbdb11 100644 --- a/types/frida-gum/package.json +++ b/types/frida-gum/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/frida-gum", - "version": "19.5.9999", + "version": "19.6.9999", "nonNpm": true, "nonNpmDescription": "frida-gum", "projects": [