Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8835085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:10:44+00:00 2026-06-14T09:10:44+00:00

I have the following interfaces: interface Ixy { X: string; Y: string; } interface

  • 0

I have the following interfaces:

interface Ixy 
{
    X: string;
    Y: string;
}
interface Ixz 
{
    X: string;
    Z: string;
}

This function:

export function update(json: Ixy) {
    var a = json.X;
}

The function is called from the following two places:

export function update1(json: Ixy) {
   update(json);
}
export function update2(json: Ixz) {
   update(json);
}

Can someone explain to me the best way I cand make this work with typescript. Right
now update1 is okay but update2 shows that the signature does not match. Is the only
way I can fix this to change the type of the json to any or is there a better way to
do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:10:46+00:00Added an answer on June 14, 2026 at 9:10 am

    There are a couple of ways to do it. Probably the best is to create a base interface Ixx which has the common property X, then extend it to create Ixy and Ixz, and then implement update with Ixx as the parameter type:

    interface Ixx 
    {
        X: string;
    }
    
    interface Ixy extends Ixx
    {
        Y: string;
    }
    interface Ixz extends Ixx
    {
        Z: string;
    }
    
    export function update(json: Ixx) {
        var a = json.X;
    }
    
    export function update1(json: Ixy) {
       update(json);
    }
    export function update2(json: Ixz) {
       update(json);
    }
    

    This works because Ixy and Ixz both extend Ixx and so would satisfy the condition json is Ixx. This works with classes extending a base class as well (or classes which extend a base interface).

    There’s not a lot of literature on TypeScript yet, so perhaps a couple of general introductions to interfaces from other languages will be useful, as this is really a cross-language question about interface use, rather than anything TS-specific.

    Java interfaces: http://docs.oracle.com/javase/tutorial/java/IandI/createinterface.html

    C# interfaces: http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following classes and interfaces: public interface IThing { string Name {
I have the following interface called IAccountService. I also have exactly the same interfaces
I have the following set of Interfaces and Classes. public interface IValidatableObject { List<string>
I have the following Interfaces: public interface ITemplateItem { int Id { get; set;
I have the following two interfaces: public interface IMembershipProvider { object Login(ILoginProviderParameters loginParameters); void
I currently have interfaces much like the following: interface IService { void Start(); IHandler
Lets say i have the following set of interfaces.... public interface IStart { void
Consider, I have the following 3 classes / interfaces: class MyClass<T> { } interface
I have following interfaces public interface IReport<TInput, TOutput> { List<TOutput> GenerateReport(TInput input); } public
imagine you have the following interfaces: public interface IInterfaceA : IInterfaceX { // //

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.