Is it possible to define a static private method in TypeScript?

My code snippet looks like this:

module Dialog {
    export class Modal {
        static createAccessModal(link: Link) {
            createModal(link);
        }
        static createAdminModal(link: Link) {
            link.Modal.MaxHeight = 600;
            link.Modal.Width = false;
            createModal(link);
        }
        static private createModal(link: Link) {

            ...
        }
    }
}

I attempted to restrict direct calls to the 'createModal' function by marking it as private. However, even though intellisense visually indicates that it's locked, I'm still able to use it without any errors. Is there a better way to achieve this restriction? Here is how I try to call the function:

Dialog.Modal.createAccessModal(link); // This call is permitted
Dialog.Modal.createModal(link); // This call should not be allowed

Additionally, I've opted for static functions throughout, as these functions are solely responsible for creating objects on the screen which then handle themselves with their own functionality (i.e., submit button). Would you consider this approach reasonable?

Answer №1

namespace Dialog {
    export namespace Modal {
        export function generateAccessModal(link: Link) {
            createModal(link);
        }
        export function generateAdminModal(link: Link) {
            link.Modal.MaxHeight = 600;
            link.Modal.Width = false;
            createModal(link);
        }
        function createModal(link: Link) {

            ...
        }
    }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Why is it that this specific ASP.NET + jQuery + JavaScript custom MVC setup isn't displaying any content?

After attempting to incorporate this JavaScript MVC example from into an ASP.NET page, I am facing issues as a beginner with jQuery. Nothing seems to show up on the page, and I'm unsure why. Update: I have included the missing HTML listbox, but now ...

Learning how to dynamically update a value in Angular based on user input

My goal is to dynamically change the output value based on user input using Angular. I have successfully implemented the functionality to increment the value, but unfortunately, when the input changes, the outputed value remains static. Below is my curren ...

Slim specific assigned parameter

Here is some code to analyze: type T = 'a' | "b" type M = { a: 1, b: 2 } function a(a: 'a') {} function m1(a: 1) {} function f<TT extends T>(t: TT, p: M[TT]) { switch (t) { case "a": { a(t) ...

The content in Angular UI Grid fails to display until the browser window is adjusted

I am currently utilizing angularjs 1.5.0 along with angular ui grid 3.1.1. In my controller, I assign the gridOptions object (which is passed to the grid directive) in the following way: $scope.gridOptions = { data: [{"mock2": 1, "mock1": 2}, {"moc ...

Issue opening react modal dialogue box

I'm encountering an issue while trying to implement the headless ui modal. I'm attempting to trigger the modal.js script from my home.js file. In my home.js file, I have the following code snippet: function Home() { const [isOpen, setIsOpen] = ...

I am struggling to make the while loop function correctly within for loops in TypeScript

Looking to obtain an array of arrays with unique values, but running into issues when while loop seems to get skipped or overlooked (possibly due to the asynchronous nature of it). Would appreciate assistance in implementing a promise within this code ...

Formatting numbers as floating point values in AngularJS

I need a text box where users can enter an amount. The input should be restricted to numbers only, with no special characters or decimal points. I have managed this using custom filters. However, I also need the entered number to automatically display as ...

What techniques can I use to merge alpha channels with compositing in images?

Utilizing an HTML5 Canvas along with the KineticJS(KonvaJS) canvas library, I have successfully incorporated an Image element. My current objective is to erase specific pixels while maintaining a certain level of transparency. The red dot erases pixels at ...

Tips for effectively organizing a collapsible list

Here is a list that I have: <ul> <li><span class="Collapsable">item 1</span> <ul> <li><span class="Collapsable">item 1.1</span></li> </ul> </ul> I am looking to create ...

MongooseError: Attempting to execute a query that has already been completed: user.findOneAndUpdate(`

I've encountered an issue while following an online tutorial. The error I'm facing with the "PATCH" function (followUser) persists even after copying the instructor's code. The strange part is that it successfully updates in mongoDB despite ...

Updating the DOM after scrolling using jQuery

jQuery hover functionality is not working correctly after scrolling. $(document).ready(function() { $('img').hover(function(){ alert('hello'); },function(){ alert('hello not'); }); }); When hoveri ...

What is preventing me from accessing the request.query parameter?

Greetings everyone, this is my debut post so I kindly ask for your patience. Our team is currently immersed in our inaugural Web-Project and we are facing some difficulties pinpointing the issues within our project. The project itself revolves around crea ...

Detecting the return of a file in an ASP.NET view to conceal an image

Is there a way to detect when ASP.NET returns a file? I recently added code to my project to show a loading gif whenever a button is pressed. <script type="text/javascript> jQuery('.btn').click(function() { jQuery".loader").show(); }); ...

Is it possible to transfer a massive number of files using node.js?

I need to asynchronously copy a large number of files, about 25000 in total. I am currently using the library found at this link: https://github.com/stephenmathieson/node-cp. Below is the code snippet I am using: for(var i = 0; i < 25000; i++ ...

When working in Shopify, I have found that I am able to easily access a JSON object from the browser console, however I have run

Currently, I am utilizing the GET/cart.js call in an asset on my theme to retrieve the cart contents in a JSON object format as shown below: var response = jQuery.getJSON('/cart.js'); Afterward, I attempt to display the contents of the object i ...

Building a typeguard in Typescript that handles errors

type VerifiedContext = Required<ApolloContext>; function authenticateUser(context: ApolloContext): context is VerifiedContext { if (!context.user) { throw new AuthenticationError("Login required for this operation"); } return true; } Here ...

Choose from the selection of options in the select tag

In my HTML document, I am working on a feature where selecting an option from one select tag should dynamically populate another select tag with specific options based on the selection. This is the code snippet I have implemented: <script type ...

Arrange the objects in the array in React based on their time and date of creation

As a newcomer to the world of React.js and Redux, I am faced with an array of objects structured like this: quizList = [ { createdDate : 1543314832505, id:5bfd1d90d4ed830001f589fc, name:'abc'}, { createdDate : 1543314152180, id:5bfd1ae8d4ed83000 ...

Real-time filtering in personalized dropdown menu with search input

I have been attempting to create a custom list filter for input using a computed property. In one file, I am developing a widget, while in another file, I am implementing it. Below is the code snippet from the widget creation file: <template> ...

Is it possible to create a graph using only links from a JSON file when using D3.js?

I am looking to extract node information from links data stored in a JSON file. My ultimate goal is to visualize this data by creating a graph with connections and edges. Here is a snippet from my sample JSON file: { "links": [ { "source":0, ...