<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ca">
	<id>http://wiki.joanillo.org/index.php?action=history&amp;feed=atom&amp;title=TypeScript</id>
	<title>TypeScript - Historial de revisió</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.joanillo.org/index.php?action=history&amp;feed=atom&amp;title=TypeScript"/>
	<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=TypeScript&amp;action=history"/>
	<updated>2026-08-29T23:41:02Z</updated>
	<subtitle>Historial de revisió per a aquesta pàgina del wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://wiki.joanillo.org/index.php?title=TypeScript&amp;diff=298968&amp;oldid=prev</id>
		<title>Joan: /* Integració de TypeScript amb Sublime Text 3 */</title>
		<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=TypeScript&amp;diff=298968&amp;oldid=prev"/>
		<updated>2022-04-19T16:40:42Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Integració de TypeScript amb Sublime Text 3&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ca&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Versió més antiga&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revisió del 16:40, 19 abr 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l235&quot; &gt;Línia 235:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Línia 235:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Autor}}, abril 2018&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Autor}}, abril 2018&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, abril 2022&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Joan</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.joanillo.org/index.php?title=TypeScript&amp;diff=298892&amp;oldid=prev</id>
		<title>Joan: /* Primer exemple */</title>
		<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=TypeScript&amp;diff=298892&amp;oldid=prev"/>
		<updated>2022-04-07T09:43:15Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Primer exemple&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ca&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Versió més antiga&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revisió del 09:43, 7 abr 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l44&quot; &gt;Línia 44:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Línia 44:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;$ tsc&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;$ tsc&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Version &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;2&lt;/del&gt;.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;8&lt;/del&gt;.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;1&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Version &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;4&lt;/ins&gt;.&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;6&lt;/ins&gt;.&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;3&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Syntax:   tsc [options] [file ...]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Syntax:   tsc [options] [file ...]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;...&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;...&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''NOTA''': si no s'instal.la correctament, és possible que la versió de Node no sigui de les últimes. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Instal.lar &lt;/del&gt;la última versió de Node. A Ubuntu:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''NOTA''': si no s'instal.la correctament, és possible que la versió de Node no sigui de les últimes. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Instal·lar &lt;/ins&gt;la última versió de Node. A Ubuntu:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;$ sudo apt-get install nodejs-legacy&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;$ sudo apt-get install nodejs-legacy&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l180&quot; &gt;Línia 180:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Línia 180:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Ja hem fet la nostra primera aplicació web basada en TypeScript.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Ja hem fet la nostra primera aplicació web basada en TypeScript.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Playground=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Playground=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*https://www.typescriptlang.org/play/index.html&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*https://www.typescriptlang.org/play/index.html&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Joan</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.joanillo.org/index.php?title=TypeScript&amp;diff=259314&amp;oldid=prev</id>
		<title>Joan: /* Instal.lació */</title>
		<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=TypeScript&amp;diff=259314&amp;oldid=prev"/>
		<updated>2020-04-21T14:57:31Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Instal.lació&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pàgina nova&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Introducció=&lt;br /&gt;
*https://www.typescriptlang.org/docs/home.html&lt;br /&gt;
&lt;br /&gt;
'''TypeScript''' és un llenguatge de programació lliure i de codi obert desenvolupat i mantingut per Microsoft. És un superconjunt (''superset'') de JavaScript, que essencialment afegeix tipat estàtic i està basat en classes.&lt;br /&gt;
&lt;br /&gt;
TypeScript extén la sintaxi de JavaScript, i per tant qualsevol codi JavaScript existent hauria de funcionar sense problemes. Està pensat per a grans projectes, els quals a través d'un compilador de TypeScript es tradueixen al codi JavaScript original.&lt;br /&gt;
&lt;br /&gt;
El framework '''Angular''' està escript amb TypeScript, i és per això important conèixer typescript abans de programar amb Angular:&lt;br /&gt;
*https://vsavkin.com/writing-angular-2-in-typescript-1fa77c78d8e8&lt;br /&gt;
=Why TypeScript?=&lt;br /&gt;
JavaScript is a great language for developing small size applications but when it comes to large applications, things start to get out of control with complex JavaScript code and many shortcomings in the language. Over the course of the last few years JavaScript has grown a lot and has become the way to go to write cross platform applications. JavaScript applications can run on all platforms including mobile, web and desktop. In that sense, an application written in JavaScript can run on any platform and browser. JavaScript has also proven to be the official language of the web. However, JavaScript when first created, was not meant for that, it was mainly designed for simple uses in small applications. With the dramatic growth in JavaScript usage, it was time to make it right and fill the gaps that JavaScript misses to have it scale to easily and effectively build medium to large size applications.&lt;br /&gt;
&lt;br /&gt;
=Tipat estàtic i dinàmic=&lt;br /&gt;
==Tipat estàtic==&lt;br /&gt;
Un llenguatge de programació utilitza un ''tipat estàtic'' quan la comprovació de tipificació es realitza durant la compilació, i no durant l'execució. Exemples: C, C++, Java. Comparat amb el ''tipat dinàmic'', el ''tipat estàtic'' permet que els errors de tipificació siguin detectats abans, i que l'execució del codi sigui més eficient i segura.&lt;br /&gt;
==Tipat dinàmic==&lt;br /&gt;
Un llenguatge de programació utilitza un ''tipat  dinàmic'' quan la comprovació de la tipificació es realitza durant l'execució en comptes de la compilació. Exemples: Javascript, Perl, Python. Comparat amb el ''tipat estàtic'', el ''tipat dinàmic'' és més flexible, a pesar d'executar-se més lentament i ser més propensos a cometre errors de programació. &lt;br /&gt;
==Tipat estàtic a TypeScript==&lt;br /&gt;
El sistema de tipus de Typescript realitza una formalització dels tipus de Javascript, mitjançant una representació estàtica dels seus tipus dinàmics. Això permet als desenvolupadors definir variables i funcions tipades sense perdre l'essència de Javascript. Poder definir els tipus durant el temps de disseny ens ajuda a evitar errors en temps d'execució, como podria ser passar el tipus de variable incorrecte a una funció.&lt;br /&gt;
&lt;br /&gt;
'''TypeScript''', A més a més dels tipus '''String''' i '''Number''' admet els següents tipus bàsics:&lt;br /&gt;
&lt;br /&gt;
*'''Boolean''': tipus de dada lògic que representa ''true'' o ''false''.&lt;br /&gt;
*'''Array''': tipus de dada estructurat que permet emmagatzemar una col.lecció d'elements.&lt;br /&gt;
*'''Tuple''': similar a l' ''array'', però amb un número fix d'elements.&lt;br /&gt;
*'''Enum''': representa el tipus enumeració.&lt;br /&gt;
*'''Any''': indica que la variable pot ser de qualsevol tipus. És molt útil a l'hora de treballar amb llibreries externes.&lt;br /&gt;
*'''Void''': indica que una funció no retornarà cap valor.&lt;br /&gt;
*'''Never''': aquest tipus representa el tipus de valorss que mai es produiran.&lt;br /&gt;
&lt;br /&gt;
Exemples de cadascun d'aquests tipus:&lt;br /&gt;
*https://www.typescriptlang.org/docs/handbook/basic-types.html&lt;br /&gt;
&lt;br /&gt;
=Primer exemple=&lt;br /&gt;
*https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html&lt;br /&gt;
Anem a fer la primera aplicació web amb TypeScript.&lt;br /&gt;
===Instal.lació===&lt;br /&gt;
El primer que hem de fer és instal.lar '''TypeScript'''. Ho podem fer de dues maneres:&lt;br /&gt;
*Via '''npm''' (''node package manager'', els paquest de gestió de Node.js)&lt;br /&gt;
*Utilitzar Visual Studio com a IDE, i instal.lar el plugin de TypeScript. Visual Studio 2017 i Visual Studio 2015 Update 3 inclou TypeScript per defecte. Recordem que TypeScript està creat i mantingut per Microsoft.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ npm install -g typescript&lt;br /&gt;
&lt;br /&gt;
$ tsc&lt;br /&gt;
Version 2.8.1&lt;br /&gt;
Syntax:   tsc [options] [file ...]&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''NOTA''': si no s'instal.la correctament, és possible que la versió de Node no sigui de les últimes. Instal.lar la última versió de Node. A Ubuntu:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo apt-get install nodejs-legacy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===script greeter.ts===&lt;br /&gt;
Amb el teu editor/IDE preferit, crea el script '''greeter.ts''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function greeter(person) {&lt;br /&gt;
    return &amp;quot;Hello, &amp;quot; + person;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
let user = &amp;quot;Jane User&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
document.body.innerHTML = greeter(user);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Fixa't que la sintaxi és Javascript (la paraula reservada ''let'' és de Javascript). Diferència entre ''var'' i ''let'':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
The difference is scoping. var is scoped to the nearest function block and let is scoped to the nearest enclosing block, which can be smaller than a function block. Both are global if outside any block.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
compilem i es genera el script ''greeter.js'':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ tsc greeter.ts&lt;br /&gt;
&lt;br /&gt;
function greeter(person) {&lt;br /&gt;
    return &amp;quot;Hello, &amp;quot; + person;&lt;br /&gt;
}&lt;br /&gt;
var user = &amp;quot;Jane User&amp;quot;;&lt;br /&gt;
document.body.innerHTML = greeter(user);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
que en aquest cas és exactament igual.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ara ja podem començar a utilitzar els avantatges de TypeScript. Afegim l'anotació tipus ''' : string''' a la funció ''person'':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function greeter(person: string) {&lt;br /&gt;
    return &amp;quot;Hello, &amp;quot; + person;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
let user = &amp;quot;Jane User&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
document.body.innerHTML = greeter(user);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
I tornem a compilar. Si la varible ''user'' no fos un String, la compilació donaria error:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ tsc greeter_v2.ts&lt;br /&gt;
greeter_v2.ts(8,35): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
De la mateixa manera, també donaria error si cridem a la funció greeter() sense arguments (no dóna error amb Javascript estàndar).&lt;br /&gt;
&lt;br /&gt;
Encara que la compilació provoqui errors, el fitxer ''greeter.js'' es crea. Es pot utilitzar ''TypeScript'' encara que hi hagi errors en el codi, però ''TypeScript'' et notifica els warnings per avisar que el programa podria no funcionar com s'espera.&lt;br /&gt;
==Interfaces==&lt;br /&gt;
Ara utilitzarem una '''interface''' que descriu objectes amb els camps ''firstName'' i ''lastName''. A TypeScript, dos tipus són compatibles si tenen la seva estructura interna compatible. Això permet implementar una ''interface'' si senzillament tenim l'estructura que necessita la ''interface'', sense reequerir la clàusula ''implements''.&lt;br /&gt;
&lt;br /&gt;
script '''person.ts''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
interface Person {&lt;br /&gt;
    firstName: string;&lt;br /&gt;
    lastName: string;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function greeter(person: Person) {&lt;br /&gt;
    return &amp;quot;Hello, &amp;quot; + person.firstName + &amp;quot; &amp;quot; + person.lastName;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
let user = { firstName: &amp;quot;Jane&amp;quot;, lastName: &amp;quot;User&amp;quot; };&lt;br /&gt;
&lt;br /&gt;
document.body.innerHTML = greeter(user);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Classes==&lt;br /&gt;
Anem a extendre el nostre exemple utilitzant ''classes''. TypeScript suporta les noves característiques de JavaScript, com ara programació orientat a objectes basat en classes.&lt;br /&gt;
&lt;br /&gt;
Anem a crear la classe ''Student'' amb un constructor i uns quants camps públics. Fixar-se bé que les ''classes'' i les ''interfaces'' treballen bé conjuntament, deixant decidir al programador el nivell d'abstracció desitjat.&lt;br /&gt;
&lt;br /&gt;
Fixar-se que l'ús públic d'arguments en el constructor és una drecera que permet crear automàticament propietats amb aquest nom.&lt;br /&gt;
&lt;br /&gt;
script '''student.ts''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Student {&lt;br /&gt;
    fullName: string;&lt;br /&gt;
    constructor(public firstName: string, public middleInitial: string, public lastName: string) {&lt;br /&gt;
        this.fullName = firstName + &amp;quot; &amp;quot; + middleInitial + &amp;quot; &amp;quot; + lastName;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
interface Person {&lt;br /&gt;
    firstName: string;&lt;br /&gt;
    lastName: string;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function greeter(person : Person) {&lt;br /&gt;
    return &amp;quot;Hello, &amp;quot; + person.firstName + &amp;quot; &amp;quot; + person.lastName;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
let user = new Student(&amp;quot;Jane&amp;quot;, &amp;quot;M.&amp;quot;, &amp;quot;User&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
document.body.innerHTML = greeter(user);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mirem el codi generat després de la compilació: '''student.js''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var Student = /** @class */ (function () {&lt;br /&gt;
    function Student(firstName, middleInitial, lastName) {&lt;br /&gt;
        this.firstName = firstName;&lt;br /&gt;
        this.middleInitial = middleInitial;&lt;br /&gt;
        this.lastName = lastName;&lt;br /&gt;
        this.fullName = firstName + &amp;quot; &amp;quot; + middleInitial + &amp;quot; &amp;quot; + lastName;&lt;br /&gt;
    }&lt;br /&gt;
    return Student;&lt;br /&gt;
}());&lt;br /&gt;
&lt;br /&gt;
function greeter(person) {&lt;br /&gt;
    return &amp;quot;Hello, &amp;quot; + person.firstName + &amp;quot; &amp;quot; + person.lastName;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var user = new Student(&amp;quot;Jane&amp;quot;, &amp;quot;M.&amp;quot;, &amp;quot;User&amp;quot;);&lt;br /&gt;
document.body.innerHTML = greeter(user);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Veiem que el codi Javascript generat és la mateixa definició d'objectes que utilitzem habitualment a Javascript. Les classes a ''TypeScript'' són senzillament una drecera al prototipus d'objectes que utilitzem habitualment a Javascript.&lt;br /&gt;
==Codi html==&lt;br /&gt;
Ara només cal ficar el codi Javascript generat en un fitxer HTML:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
    &amp;lt;head&amp;gt;&amp;lt;title&amp;gt;TypeScript Greeter&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;
    &amp;lt;body&amp;gt;&lt;br /&gt;
        &amp;lt;script src=&amp;quot;student.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
    &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Ja hem fet la nostra primera aplicació web basada en TypeScript.&lt;br /&gt;
=Playground=&lt;br /&gt;
*https://www.typescriptlang.org/play/index.html&lt;br /&gt;
Tenim diferents exemples que podem explorar.&lt;br /&gt;
&lt;br /&gt;
Concretament ens fixarem en l'exemple de l'herència. Veiem que és fàcil implementar l'herència a TypeScript, i en canvi és molt complicat de fer-ho directament amb Javascript pur (''vanilla'').&lt;br /&gt;
&lt;br /&gt;
Feina per l'alumne: fer funcionar l'exemple de l'herència (''animals''), doncs sobre aquest exemple farem una pràctica.&lt;br /&gt;
=Característiques=&lt;br /&gt;
*TypeScript solves all the problems with JavaScript. It focuses on the developers experience and productivity. TypeScript starts from the same syntax and semantics that millions of JavaScript developers know today. TypeScript compiles to JavaScript code which runs on any browser, any host, any OS, or in any JavaScript engine that supports ECMAScript 3 (or newer).&lt;br /&gt;
&lt;br /&gt;
*TypeScript has now become the smart choice for writing a modern web or JavaScript-based application. It is also known as “JavaScript that scales”. Some modern web development libraries like Angular (starting version 2) actually have TypeScript as the required language of development in order to be able to use the library in your application.&lt;br /&gt;
&lt;br /&gt;
*TypeScript enables JavaScript developers to use highly-productive development tools and practices like static checking and code refactoring when developing applications. Types are optional, and type inference allows a few type annotations to make a big difference to the static verification of your code. Types let you define interfaces between software components and gain insights into the behavior of existing JavaScript libraries.&lt;br /&gt;
&lt;br /&gt;
*There is a lot of supporting tools for TypeScript in almost all the development editors or IDEs.&lt;br /&gt;
&lt;br /&gt;
*TypeScript allows team based development where different members of the team can work on different components of the application using modules.&lt;br /&gt;
&lt;br /&gt;
*TypeScript catches issues with your code early during development that normally can't be caught in JavaScript until code is run in the browser, resulting in runtime exceptions and errors in your application.&lt;br /&gt;
&lt;br /&gt;
*TypeScript is open source with a huge community of support. TypeScript is the third most-loved programming technology in the 2017 Stack Overflow Developer Survey.&lt;br /&gt;
&lt;br /&gt;
*TypeScript is cross platform and can run on any browser, any host, any OS.&lt;br /&gt;
&lt;br /&gt;
*TypeScript is backwards compatible and can accept all your existing JavaScript code as valid TypeScript code.&lt;br /&gt;
&lt;br /&gt;
*TypeScript also implements all the features of ECMAScript 2015 (or ES6) that solves many of the core shortcomings of JavaScript, like classes, modules, arrow functions and more. ES6 is the next version of JavaScript but although it exists, it doesn't run on any browser today and thus is not being used. TypeScript allows developers to use all the ES6 features by providing syntactic sugar on top of ES5 which the TypeScript compiler will transcompile into ES5 compliant JavaScript that today's browser can execute.&lt;br /&gt;
&lt;br /&gt;
*TypeScript can be used to write both client side code (that runs on a browser) and server side code (that runs on the application server) using the Node.js library. That means with TypeScript, you only learn one language to become a full stack web developer. This is not the case with JavaScript today since JavaScript only runs on the client side and can't be used to write server side code, developers need to develop server side applications with other languages like C#, C++, Java, PHP, ..etc. TypeScript implemented features from ES6&lt;br /&gt;
&lt;br /&gt;
*Strongly typed variables&lt;br /&gt;
*Strongly typed function parameters&lt;br /&gt;
*Classes&lt;br /&gt;
*Interfaces&lt;br /&gt;
*Inheritance&lt;br /&gt;
*Modules which help divide things into building blocks so more than one person can work on developing one application.&lt;br /&gt;
*Support for code refactoring tools because everything in TypeScript can have a type.&lt;br /&gt;
*Support for libraries like Angular and React to use with TypeScript.&lt;br /&gt;
&lt;br /&gt;
=Integració de TypeScript amb Sublime Text 3=&lt;br /&gt;
Per treure'n el màxim de profit, utilitzem la última versió de Sublime Text, la 3.&lt;br /&gt;
*https://www.sublimetext.com/3&lt;br /&gt;
*https://github.com/Microsoft/TypeScript-Sublime-Plugin&lt;br /&gt;
Per instal.lar el plugin, des de Sublime Text 3 fem &lt;br /&gt;
&lt;br /&gt;
*Preferences &amp;gt; Package Control &amp;gt; Install Packages&lt;br /&gt;
&lt;br /&gt;
Un cop instal.lat el plugin de TypeScript, configurem el nostre script per tal de què realci la sintaxi.&lt;br /&gt;
*View &amp;gt; Syntax &amp;gt; TypeScript&lt;br /&gt;
*Tools &amp;gt; Build System &amp;gt; TypeScript&lt;br /&gt;
Ara ja podem compilar el script .tsc directament, amb la drecera Ctrl-B o F7 (''build'') (smb la qual cosa ens estalviem de tenir la consola oberta).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Autor}}, abril 2018&lt;/div&gt;</summary>
		<author><name>Joan</name></author>
		
	</entry>
</feed>