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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:45:30+00:00 2026-06-12T09:45:30+00:00

UPDATE – the context of this question was pre-TypeScript 1.4. Since that version, my

  • 0

UPDATE – the context of this question was pre-TypeScript 1.4. Since that version, my first guess has been supported by the language. See the update to the answer.


I can declare f to be a function that accepts a string and returns a string:

var f : (string) => string

And I can declare g to be an array of string:

var g : string[]

How can I declare h to be an array of “function that accepts a string and returns a string”?

My first guess:

var h : ((string) => string)[]

That seems to be a syntax error. If I take away the extra parentheses then it’s a function from string to array of string.

  • 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-12T09:45:31+00:00Added an answer on June 12, 2026 at 9:45 am

    I figured it out. The problem is that the => for a function type literal is itself merely syntactic sugar and doesn’t want to compose with [].

    As the spec says:

    A function type literal of the form

    ( ParamList ) => ReturnType

    is exactly equivalent to the object type literal

    { ( ParamList ) : ReturnType }

    So what I want is:

    var h : { (s: string): string; }[]
    

    Complete example:

    var f : (string) => string
    
    f = x => '(' + x + ')';
    
    var h : { (s: string): string; }[]
    
    h = [];
    
    h.push(f);
    

    Update:

    Judging from this changeset parentheses will be allowed in type declarations in 1.4, so the “first guess” in the question will also be correct:

    var h: ((string) => string)[]
    

    Further Update It is in 1.4!

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

Sidebar

Related Questions

UPDATE This is an old question for an old version of Xcode. It turned
UPDATE: I've been playing around with this more, and it seems like tmux's clear-history
Update : This is no longer an issue from C# 6, which has introduced
Update : I found almost exact similar question , yet it has slightly different
UPDATE: I made a mistake in my debugging - this question is not relavent
Update 2018 : This question was asked long before PostCSS existed, and I would
Update: The index.php file here: /public_html/d/index.php includes: /public_html/d/core/source/class.File1.php This Class.File1.php here has this include
UPDATE The second after I posted this question, thanks to the syntax highlighting of
UPDATE I've deployed a live version on my FTP Link here ! Hopefully this
UPDATE: I found a Scipy Recipe based in this question! So, for anyone interested,

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.