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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:33:57+00:00 2026-06-13T17:33:57+00:00

I wanted to move to TypeScript from traditional JS because I like the C#-like

  • 0

I wanted to move to TypeScript from traditional JS because I like the C#-like syntax.
My problem is that I can’t find out how to declare static classes in TypeScript.

In C#, I often use static classes to organize variables and methods, putting them together in a named class, without needing to instatiate an object.
In vanilla JS, I used to do this with a simple JS object:

var myStaticClass = {
    property: 10,
    method: function(){}
}

In TypeScript, I would rather go for my C-sharpy approach, but it seems that static classes don’t exist in TS.
What is the appropriate solution for this problem ?

  • 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-13T17:33:57+00:00Added an answer on June 13, 2026 at 5:33 pm

    TypeScript is not C#, so you shouldn’t expect the same concepts of C# in TypeScript necessarily. The question is why do you want static classes?

    In C# a static class is simply a class that cannot be subclassed and must contain only static methods. C# does not allow one to define functions outside of classes. In TypeScript this is possible, however.

    If you’re looking for a way to put your functions/methods in a namespace (i.e. not global), you could consider using TypeScript’s modules, e.g.

    module M {
        var s = "hello";
        export function f() {
            return s;
        }
    }
    

    So that you can access M.f() externally, but not s, and you cannot extend the module.

    See the TypeScript specification for more details.

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

Sidebar

Related Questions

I wanted to hold UIView and Move like the way we all can change
I wanted to move my projects in eclipse from SDK rev 15 to rev
I wanted to move from jboss AS 6 to 7 with hibernate 4 support
I wanted to move our existing repository (from location A) to a new linux
Say I have function X in file A, and I wanted to move that
I have web.rb file that works fine. I wanted to move all require files
I wanted to move a sql file to my staging server that was related
I am a new to magento. I wanted to move the search bar from
How can I move from the current view to another view? My current view
I've created small database under SQL Server 2008 . Now i wanted to move

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.