Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript, Html & JS file nesting in Visual Studio 2015

How do I manage/control the nesting of TypeScript files in Visual Studio?

I am getting a mix of nested & not nested files, I'm not sure how/why, as shown below.

Nested & non-nested files

like image 817
Sean Avatar asked Jul 28 '15 07:07

Sean


People also ask

Can I use TypeScript in HTML?

A JavaScript library has already been developed for this purpose - it's called TypeScript Compile, and it allows typescript to be embedded in HTML (as shown above.)

What is TypeScript in HTML?

TypeScript is a superset that needs to compile to plain JavaScript. It offers more control over your code since it uses type annotations, interfaces, classes, and static type checking to throw errors at compile-time. TypeScript helps to enhance code quality and understandability, especially with a large codebase.

Can I use TypeScript with HTML and CSS?

You can't use TypeScript directly in a web page the same way you'd be able to use JavaScript -- that is, you can't add a <script> tag and point directly at a TypeScript file as your src, nor can you enter TypeScript between script tags. TypeScript has to be compiled into JavaScript for a web browser to understand it.

How do you call a TypeScript function in HTML?

You need to arrange things so the function is in scope and then you can just call it with {{getConfigurations(param)}} but people can't give you proper help without more info.


1 Answers

The default for JavaScript files in a TypeScript project is to exclude them rather than nest them - but there are several ways you can nest them if you prefer.

You can hack the registry... or hand-crank your project file's XML... but the easier option is to let Mads Kristensen do it for you with his File Nesting Extension.

You right-click on the .js file and select "Nest File". It will then show a dialog for you to choose the file to nest under (and usually guesses the right answer).

like image 132
Fenton Avatar answered Oct 02 '22 22:10

Fenton