Skip to content

Tag: typescript

TypeScript in combination with BreezeJS

I’m currently working on a project prototype with TypeScript in combination with BreezeJS. I’m using the HotTowel template from John Papa and wrote my own TypeScript ViewModels for each HTML page. To use normal JavaScript libs you need a TypeScript file file.d.ts which is some sort of interface class so TypeScript knows which JavaScript functions there are. With this combination

TypeScript static classes

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

Set window.location with TypeScript

I am getting an error with the following TypeScript code: I am getting an underlined red error for the following: The message says: Does anyone know what this means? Answer window.location is of type Location while .attr(‘data-href’) returns a string, so you have to assign it to window.location.href which is of string type too. For that replace your following line:

Why can I access TypeScript private members when I shouldn’t be able to?

I’m looking at implementation of private members in TypeScript, and I find it a little confusing. Intellisense doesn’t allow to access private member, but in pure JavaScript, it’s all there. This makes me think that TS doesn’t implement private members correctly. Any thoughts? Answer Just as with the type checking, the privacy of members are only enforced within the compiler.