An warware: samfurin rubutu na gaba

A cikin sararin sararin samaniya na shirye-shirye, TypeScript yana tsaye a matsayin supernova mai ฦ™arfi wanda ya haskaka yanayin JavaScript ta hanyar ฦ™ara nau'ikan iri. Wannan yana ba mu damar rubuta ฦ™arin amintattun lambobi masu iya kiyayewa. Bari mu zurfafa cikin wannan daula mai ban sha'awa, muna zana hoton samfuri mai sauฦ™i na TypeScript, matsalolin da zai iya warwarewa, da mataki-mataki na amfani da shi.

Fahimtar TypeScript

Me yasa muke buฦ™atar TypeScript

TypeScript, babban juzu'i na JavaScript, yana magance manyan kasawa na JavaScript, yana mai da shi zaษ“i don aikace-aikace masu rikitarwa. Lokacin da ake mu'amala da ma'auni masu girma, yanayin yanayin JavaScript na iya haifar da kiyayewa da warware matsalolin. Wannan shine inda TypeScript ya shigo cikin wasa, yana ba da nau'ikan iri don ingantaccen nau'in dubawa da kammalawa ta atomatik.

Gabatarwar Samfuran TypeScript

class BasicTemplate {
  constructor(public message: string) {}

  displayMessage() {
    return this.message;
  }
}

let myTemplate = new BasicTemplate('Hello, TypeScript!');
console.log(myTemplate.displayMessage());

Wannan ainihin samfurin Nau'in Nau'in ya ฦ™unshi aji, BasicTemplate, wanda ke riฦ™e da aikin ginin da ke fara mallakar dukiyar jama'a, 'saฦ™o'. Wannan ajin kuma yana ba da hanyar 'nuna saฦ™o()' don nuna saฦ™on.

Yadda Maganin TypeScript ke Aiki

A cikin samfurin mu na TypeScript, ajin 'BasicTemplate' an ayyana shi don tattara cikakkun bayanai na sarrafa saฦ™o. Amfani da aji a cikin TypeScript yana sa ya zama mafi sauฦ™i kuma mai hankali don tsarawa da tsara lambar.

  • 'Maginin' hanya ce ta musamman don ฦ™irฦ™ira da fara abu.
  • Mun fayyace hanya 'nuna saฦ™o()' a cikin ajin mu. Hanya ita ce aikin da ke da alaฦ™a da abu, ko kuma, saษ“ani, aikin aji.

Daga nan sai mu sanya ajin tare da 'bari myTemplate = sabon BasicTemplate('Hello, TypeScript!');' kuma daga ฦ™arshe mu shiga saฦ™on a kan na'urar bidiyo. Gabaษ—aya tsarin tsarin aiki yana manne da ฦ™a'idodin shirye-shiryen da ya dace da abu.

Fa'idodin TypeScript

Samfurin TypeScript yana ba da fa'idodi masu yawa akan daidaitaccen JavaScript. Ta hanyar kunna nau'ikan madaidaici, TypeScript yana rage yuwuwar kurakurai na lokacin aiki, yana mai da gyara kuskuren ฦ™arancin gogewa mai raษ—aษ—i. Bugu da ฦ™ari, yana samar da ci gaba ta atomatik kammalawa, kewayawa, da sake fasalin, yana sa shirye-shiryen ya fi ฦ™arfi da inganci.

TypeScript yana ba da ra'ayi na "JavaScript na gaba," yana ba masu haษ“aka damar amfani da fasalulluka na JavaScript na gaba waษ—anda injunan JavaScript ba su da tallafi a halin yanzu. Yana sa TypeScript ya zama mai tallata sabbin abubuwan JavaScript, yana tabbatar da masu haษ“akawa ba sa buฦ™atar jira don aiki da amfani da sabbin abubuwa.

Idan ya zo ga fashion slant abubuwa, bask a cikin daular Dior ta marigayi 1940 ta New Look, a m motsi daga austere, maza styles na yakin. A nan mun haษ—u da ma'auni ma'auni, kafadu masu laushi, da yalwar masana'anta a kusa da kwatangwalo. Don ฦ™irฦ™irar wakilcin wannan zamanin, yi tunanin cinched kugu da siket masu girma a cikin m launuka. Wannan game da bikin mace, alheri, da fara'a. Gaskiya mai ban sha'awa: Wannan salo daban-daban na bayan yaฦ™i ya kasance da farko an ษ“ata masa rai saboda amfani da yadudduka da suka wuce gona da iri a lokacin rabon masana'anta.

Fashion, kamar TypeScript, harshe ne don bayyana kai. Dukansu sun haษ—a da juyin halitta - ษ—aya na salo, ษ—ayan JavaScript - amma a ฦ™arshensa duka, suna nuna kyawun canji da ฦ™ima.

Shafi posts:

Leave a Comment