You can use the object de-structuring syntax:

createUser(parent: any, { data }: { data: UserCreateInput }, context: any) {
    return context.prisma.createUser(data)
}

Unfortunately it is required you write data twice. There is a proposal to fix this but there are issues around this.

Answer from Titian Cernicova-Dragomir on Stack Overflow
🌐
Marius Schulz
mariusschulz.com › blog › typing-destructured-object-parameters-in-typescript
Typing Destructured Object Parameters in TypeScript — Marius Schulz
July 23, 2019 - If no settings object is passed at all, the empty object literal {} is being destructured. Because it doesn't specify a value for the pretty property, its fallback value true is returned: function toJSON(value: any, { pretty = true }: { pretty?: boolean } = {}) { const indent = pretty ? 4 : 0; return JSON.stringify(value, null, indent); } Here's what the TypeScript compiler emits when targeting "ES5":
Discussions

Simplify object destructuring in argument
Hello, when doing some prototyping and playing with object destructuring in function argument I've noticed that I must duplicate identifier names in type information and if there are many varia... More on github.com
🌐 github.com
6
March 25, 2017
Why is function parameter destructuring so bad in TypeScript?
GitHub issue on this topic: https://github.com/Microsoft/TypeScript/issues/7576 More on reddit.com
🌐 r/typescript
11
1
May 24, 2023
typescript - Destructuring a function parameter object and ...rest - Stack Overflow
I'd like to write a function that takes an object parameter and captures all the remaining parameters in a variable. The goal is to allow the function to receive named parameters (as opposed to More on stackoverflow.com
🌐 stackoverflow.com
Narrowing the type of destructured object arguments
Suggestion 🔍 Search Terms destructuring, narrowing, parameters, arguments ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/J... More on github.com
🌐 github.com
3
March 11, 2022
🌐
DEV Community
dev.to › andreasbergstrom › finding-the-balance-when-to-use-object-destructuring-and-when-to-avoid-it-1f98
Finding the Balance: When to Use Object Destructuring and When to Avoid It - DEV Community
April 26, 2026 - Object destructuring on function parameters gives TypeScript the named arguments it doesn't have natively — function greet({ name, greeting = 'Hello' }: GreetingOptions) reads as self-documenting at the call site, defaults fall out for free, ...
🌐
GitHub
github.com › microsoft › TypeScript › issues › 14856
Simplify object destructuring in argument · Issue #14856 · microsoft/TypeScript
March 25, 2017 - Proposal: My suggestion would be that destructuring in function argument position would allow type information definition if object type is not explicitly defined: function mainLayoutComponent({banners: Component, profile: Component, cart: Component}): any { }
Author   microsoft
🌐
Medium
medium.com › @rileyhilliard › es6-destructuring-in-typescript-4c048a8e9e15
ES6 Destructuring in TypeScript. A quick look at ES6 destructure… | by Riley Hilliard | Medium
April 16, 2019 - The correct way to handle TypeScript functional destructuring is to define an interface and reference the interface after the destructure. TypeScript is then able to understand that the function takes an object argument that is of the shape ...
🌐
Reddit
reddit.com › r/typescript › why is function parameter destructuring so bad in typescript?
r/typescript on Reddit: Why is function parameter destructuring so bad in TypeScript?
May 24, 2023 -

Function parameter destructuring in JavaScript is glorious and I love it. It's clean, simple, readable, and almost intuitive. However, in TypeScript, parameter destructuring is ugly and tedious.

A sample taken from an online tutorial:

function getObjValues({ key1, key2 }: { key1: string; key2: number }) {}

Could this be any more redundant? Is there not any way to do this without repeating object keys more than once? Even with an interface, that still requires a separate definition and creates just as much (if not more) redundancy.

One of JS's biggest pros, in my opinion, is the cleanliness of inline function parameter destructuring. I'm disappointed that this feature has not made its way over to TypeScript.

🌐
TutorialsPoint
tutorialspoint.com › what-is-parameter-destructuring-in-typescript
What is parameter destructuring in TypeScript?
January 20, 2023 - In TypeScript, parameter destructuring is unpacking the argument object into separate parameter variables. For example, suppose we have passed the object with multiple properties as an argument of any function. In that case, we can destructure the ob
🌐
Bobby Hadz
bobbyhadz.com › blog › typescript-object-destructuring-function-parameters
Destructuring Object parameters in TypeScript functions | bobbyhadz
When destructuring object parameters in a function, separate the destructured parameters and the type for the specific properties with a colon.
Find elsewhere
Top answer
1 of 2
14

You can use destructuring assignment directly in the function arguments:

interface IMyType { 
    a: number;
    b: number;
    c: number;
    d: number;
    [k: string]: number; // use this if you don't know the name of the properties in 'rest'
}

const obj: IMyType = { a: 1, b: 2, c: 3, d: 4 }

// Normal destructuring
const { a, b, ...rest } = obj;
console.log(rest); // {c: 3, d: 4}

// Directly in function arguments
const fn = ({ a, b, ...rest }: IMyType) => { console.log(rest); }

console.log(fn(obj)); // {c: 3, d: 4}
2 of 2
10

UPDATE:

Given the PR at microsoft/TypeScript#28312, you could now use generics, like this:

const myfun1 = <T extends IMyProps>(p: T) => {
    const { a, b = 'hello', ...rest } = p;
    a; // string
    b; // number | 'hello'
    rest; // const rest: Pick<T, Exclude<keyof T, "a" | "b">>
}

in which the rest variable is inferred to be of type Omit<T, "a" | "b">, which is probably what you want.


Pre TS4 answer

I think object destructing with the rest operator in TypeScript corresponds to the index signature on the type of the destructured object if you have pulled off all the explicitly named properties already. That means you would have the same restriction where the types of the rest properties would have to be at least as wide as the union of all the explicitly labeled properties. In your case, you could extend IMyProps with an index signature like this:

interface IMyPropsWithIndex {
  a: string
  b?: number
  [k: string]: string | number | undefined
}

since the type of a is string and the type of b is number | undefined. You could add more stuff to the union but you couldn't make it something narrower like string. If that's okay with you, then the way to do destructuring would be something like this:

const myfun1 = (p: IMyPropsWithIndex) => {
  const { a, b = 'hello' , ...rest } = p;
  a; // string
  b; // number | 'hello'
  rest; // {[k: string]: string | number | undefined}
}

If you inspect the types of the variables, you get something like the above.


Playground link to code

🌐
LinkedIn
linkedin.com › pulse › destructured-object-parameter-typescript-sir-hoe-teo
Destructured Object Parameter with Typescript
January 6, 2019 - In Typescript, one of the way to add type annotation to function parameters is by appending the variable with a colon and a type, like this: function sayHello(first: String, last: String) { return `Hello ${first} ${last}`; ... Pretty simple right?
🌐
Gitbooks
unional.gitbooks.io › typescript › content › pages › 02-javascript-syntax › object-destructuring.html
Object Descructuring · typescript
In this case, you need all properties in the context variables, not only those you use within your function. In that case, do object destructuring in the function body.
🌐
Byby
byby.dev › ts-object-destructuring
Object destructuring with types in TypeScript
// An object with two properties const person = { name: "Alice", age: 25, hobby: "reading" }; // Destructuring the name and hobby properties and assigning default values const { name, hobby = "reading" } = person; // Destructuring the name property and omitting the rest const { name, ...others } = person; // Destructuring the name and age properties and renaming them to firstName and years const { name: firstName, age: years } = person; In TypeScript, you can also specify the type of the object or the properties that you are destructuring.
🌐
GitHub
github.com › microsoft › TypeScript › issues › 48220
Narrowing the type of destructured object arguments · Issue #48220 · microsoft/TypeScript
March 11, 2022 - In general, there is no point in passing arguments to functions that can't even see them - destructuring hides the original object, and the function only receives the individual properties; since it can't access the object itself, it ultimately ...
Author   microsoft
🌐
Medium
medium.com › @kacar7 › destructured-function-parameters-with-type-annotations-in-typescript-e5ac47866900
Destructured function parameters with type annotations in TypeScript | by kacar | Medium
June 3, 2025 - function greet({ name }: { name: string }) { console.log(`Hello, ${name}`); } greet({ name: "John" }); // Output: Hello, John · We destructured the object parameter so that we could directly use name.
🌐
Barbarian Meets Coding
barbarianmeetscoding.com › blog › argument-destructuring-and-type-annotations-in-typescript
Argument Destructuring and Type Annotations in TypeScript | Barbarian Meets Coding
May 13, 2016 - But when I tried to call that function everything exploded! say() // => Uncaught ReferenceError: something is not defined · What? What? What? I asked myself… isn’t TypeScript supposed to be a superset of ES6? Then I realized that type annotations syntax conflicts with ES6 destructuring syntax. For instance, you can use the : with destructuring to extract and project a value to a different variable than in the original object:
🌐
Webdevtutor
webdevtutor.net › blog › typescript-destructuring-arguments
A Comprehensive Guide to TypeScript Destructuring Arguments
In this guide, we will explore different ways to use TypeScript destructuring for function arguments. interface User { name: string; age: number; } function processUser({ name, age }: User) { console.log(`Name: ${name}, Age: ${age}`); } const user = { name: 'Alice', age: 30 }; processUser(user); In the example above, we define a User interface and a function processUser that destructures the name and age properties from the User object.
🌐
Webdevtutor
webdevtutor.net › blog › typescript-arguments-destructuring
Mastering Typescript Arguments Destructuring
In Typescript, arguments destructuring is a powerful feature that allows you to extract values from objects or arrays and assign them to variables in a concise and readable way. This technique can greatly simplify your code and make it more maintainable. Let's explore how you can leverage arguments ...
Top answer
1 of 1
60

To add type declarations to destructured parameters you need to declare the type of the containing object.

From the typescript documentation:

... Confusingly, the colon here does not indicate the type. The type, if you specify it, still needs to be written after the entire destructuring...

let { a, b }: { a: string, b: number } = o;

A PSA about deeply nested destructuring:

Use destructuring with care. As the previous example demonstrates, anything but the simplest destructuring expression is confusing. This is especially true with deeply nested destructuring, which gets really hard to understand even without piling on renaming, default values, and type annotations. Try to keep destructuring expressions small and simple. You can always write the assignments that destructuring would generate yourself.

Destructuring function parameters

In a function, this is how you would declare types for destructured parameters:

export default ({ a, b }: {a: string, b: number}) => (
  ...
);

This looks pretty bad on a longer example though:

export default ({
  input: { name, onChange, value, ...restInput },
  meta,
  ...rest
}: {
  input: { 
    name: string, onChange: ()=>void, value:string, ...restInput 
  }, meta: object
}) => (
  ...
);

Looks pretty bad, so the best you can do here is to declare an interface for your parameters and use that instead of inline types:

interface Params {
  input: { 
    name: string;
    onChange: ()=>void;
    value: string;
  }; 
  meta: object;
}

export default ({
  input: { name, onChange, value, ...restInput },
  meta,
  ...rest
}: Params) => {};

Playground

Article with much more

Rest parameters

For the rest parameters, depending on what you expect these types to be, you can use a index signature:

interface Params {
  // This needs to match the other declared keys and values
  [key: string]: object;
  input: { 
    [key: string]: string | (() => void);
    name: string;
    onChange: ()=>void;
    value: string;
  }; 
  meta: object;

}

export default ({
    input: { name, onChange, value, ...restInput },
    meta,
    ...rest
}: Params) => { };

This will give ...rest a type of {[key: string]: object} for example.

Rest parameter playground

🌐
xjavascript
xjavascript.com › blog › typescript-destructuring-in-function-parameter
Mastering TypeScript Destructuring in Function Parameters — xjavascript.com
Object destructuring in function parameters is used when you pass an object as an argument to a function and want to extract specific properties from it.
🌐
David Walsh
davidwalsh.name › destructuring-function-arguments
Destructuring and Function Arguments
April 3, 2018 - I see benefits with deconstructing with typing (via TypeScript) or having default values, but using it with just the deconstruction can lead to a lot of confusion in calling that function ie, the object param must have the necessary keys, in fact any object with those keys could be passed into the function, and if a user doesn’t know the function signature it gets messy and hard to follow.