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 8809549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:54:14+00:00 2026-06-14T02:54:14+00:00

I have the following function: function getAdminParams(entity) { params = {}; params = {

  • 0

I have the following function:

function getAdminParams(entity) {
   params = {};
   params = {
                pk: "0006000",
                param: "?pk=0006000",
                table: "Content",
                success: true
            };
  return params;
}

In another file I use this function like this:

params = getAdminParams(entity);
    if (params.success) {

Is there a way that I could use intellisense so that the params object
shows as having a “success” parameter? I saw that Typescript has classes and interfaces but I am not sure how or if I can use these as a return type.

  • 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-14T02:54:16+00:00Added an answer on June 14, 2026 at 2:54 am

    If you define params as an interface, then you can use a colon after the function parentheses to declare it as the return type of getAdminParams(). Like this:

    interface IParams {
        success: bool;
        pk: string;
        // etc...
    }
    
    function getAdminParams(entity): IParams {
        params = {
                    pk: "0006000",
                    success: true
                    // etc...
                };
        return params; // If the properties assigned do not fulfill the IParams interface, this will be marked as an error.
    }
    
    params = getAdminParams(entity);
    if (params. // Intellisense should offer success and pk and any other properties of IParams).
    

    Within getAdminParams you could explicitly declare params as a new IParams, but type inference will set up the intellisense for you even if you don’t, as long as the properties you assign to the params object fulfill the contract specified in the IParams interface.

    Of course your return type could be a class, or a string, or any other type, and you would declare that using the function f(): returnType syntax in just the same way.

    The language specification covers all of this in great detail, or there is a shorter introduction here: http://www.codeproject.com/Articles/469280/An-introduction-to-Type-Script or a similar SO question here: How to declare Return Types for Functions in TypeScript

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

Sidebar

Related Questions

I have the following function, it will always return True. Any ideas why and
have the following function on my collection : getFiltered: function (status, city) { return
I have the following function to remove a DOM element div, $('#emDiv').on(click, ':button[data-emp-del=true]', function
I have the following function inside my module. Function Colorize(myValue) ActiveCell.Select Selection.Font.Bold = True
I have following function that converts normal DataTable to Pivot Table. But I have
I have following function: in a.aspx.vb page: If a = True Then 'do something
I have following function, which decrypts a base64 file and writes it to a
I have following function which returns Table . create Function FN(@Str varchar(30)) returns @Names
I have the following function: public void Test(IDataContext context) { return (From c In
I have the following jQuery function: function GetGrandparentDiv(item) { return item.parents('div:eq(1)'); } Which is

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.