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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:07:43+00:00 2026-06-12T22:07:43+00:00

headjs does some very crazy JavaScript type things to its API. For instance it

  • 0

headjs does some very crazy JavaScript type things to its API. For instance it takes an arbitrary number of strings (not a string array) for a function. Sometimes it ends that same function call, you can optionally end it with a function, for example.

head.js("scripturl1", "scripturl2",...,callback);

You can also (just as easily) do the following

head.js({scriptlabel:"scripturl1"},{scriptlabel2:"scripturl2"},...., callback);

My question is how the HECK do we describe that in a declaration file? I am all ears here as my current pass seems completely wrong.

  • 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-12T22:07:44+00:00Added an answer on June 12, 2026 at 10:07 pm

    The TS language spec refers to variable number/spread parameters as “Rest Parameters”. An example interface with a function signature that accepts rest params:

    interface IExample {
        fn : (...args : any[]) => any;
    }
    
    var x : IExample = {
        fn: function(...args : any[]) {
            for (var i = 0, arg; arg = args[i]; i++) {
                console.log(arg);
            }
        }
    }
    
    x.fn(1);
    x.fn(1, 2);
    x.fn("cat", "dog", "mouse");
    

    Unfortunately, there are some limitations. The “Rest Parameter” has to be the last one in a function’s signature — so you won’t be able to capture the type of the callback parameter since it is after the repeating parameter.

    If it wasn’t, you would have been able to do something like this:

    var fn = function(cb: Function, ...args : string[]) {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anybody know, off the top of your heads, a Javascript solution for calculating
Possible Duplicate: How do I compare two strings in Perl? Why does this script
Does it make sense to use HeadJS when you only want to load in
I get the message literal does not match format string. For instance, here are
I'm using Head js to load my javascript files in parallel. I added head
Really basic question I'm sure for some of you Java heads out there. I
I have inherited some code from a guy whose favorite past time was to
Disclaimer: this question is purely informational and does not represent an actual problem I'm
Ideally I'm looking for a Javascript resource loader that will: (1) Allow me to
Today I got our svn repository cloned into git. I had some uncommitted work

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.