├── module1 ├── dist │ ├── 1.10.js │ ├── 1.4.js │ ├── 1.5.js │ ├── 1.6.js │ ├── 1.7.js │ ├── 1.8.js │ ├── 1.9.js │ ├── index.js │ └── test.js └── src │ ├── 2.10.ts │ ├── 2.11.ts │ ├── 2.12.ts │ ├── 2.4.ts │ ├── 2.5.ts │ ├── 2.6.ts │ ├── 2.7.ts │ ├── 2.8.ts │ ├── 2.9.ts │ └── index.ts ├── module2 ├── 3.1.ts ├── 3.10.ts ├── 3.11.ts ├── 3.2.ts ├── 3.3.ts ├── 3.4.ts ├── 3.5.ts ├── 3.6.ts ├── 3.7.ts ├── 3.8.ts └── 3.9.ts ├── module3 ├── 4.1.ts ├── 4.10.ts ├── 4.2.ts ├── 4.3.ts ├── 4.4.ts ├── 4.5.ts ├── 4.6.ts ├── 4.7.ts ├── 4.8.ts └── 4.9.ts └── tsconfig.json /module1/dist/1.10.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | { 3 | var fullstackDeveloper = { 4 | skills: ["HTML", "CSS", "EXPRESS"], 5 | designation1: "Frontend Developer", 6 | designation2: "Backend Developer", 7 | }; 8 | // 9 | } 10 | -------------------------------------------------------------------------------- /module1/dist/1.4.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // { 3 | // // Basic Data Type 4 | // //string 5 | // let firstName: string = "mezba"; 6 | // //number 7 | // let roll: number = 123; 8 | // //boolean 9 | // let isAdmin: boolean = true; 10 | // // undefined 11 | // let x: undefined = undefined; 12 | // // null 13 | // let y: null = null; 14 | // let d: number; 15 | // d = 123; 16 | // // Array 17 | // let friends: string[] = ["rachel", "monica"]; 18 | // let eligibleRollList: number[] = [1, 3]; 19 | // eligibleRollList.push("dd"); 20 | // // tuple --> array --> order --> type of values 21 | // let coordinates: [number, number] = [1, 5]; 22 | // let ageName: [number, string, boolean] = [50, "Mr.X", true]; 23 | // ageName[0] = 67; 24 | // } 25 | -------------------------------------------------------------------------------- /module1/dist/1.5.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // { 3 | // // Reference Type --> Object 4 | // const user: { 5 | // readonly company: string; // type --> literal types 6 | // firstName: string; 7 | // middleName?: string; // optional type 8 | // lastName: string; 9 | // isMarried: boolean; 10 | // } = { 11 | // company: "Programming Hero", 12 | // firstName: "Mezbaul", 13 | // lastName: "Abedin", 14 | // isMarried: true, 15 | // }; 16 | // user.company = "PH"; 17 | // } 18 | -------------------------------------------------------------------------------- /module1/dist/1.6.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // { 3 | // //Learning function 4 | // // Normal Function 5 | // // Arrow Function 6 | // function add(num1: number, num2: number = 10): number { 7 | // return num1 + num2; 8 | // } 9 | // add(2, "2"); 10 | // const addArrow = (num1: number, num2: number): number => num1 + num2; 11 | // // object --> function --> method 12 | // const poorUser = { 13 | // name: "Mezba", 14 | // balance: 0, 15 | // addBalance(balance: number): string { 16 | // return `My new balance is : ${this.balance + balance}`; 17 | // }, 18 | // }; 19 | // const arr: number[] = [1, 4, 10]; 20 | // const newArray: number[] = arr.map((elem: number): number => elem * elem); 21 | // } 22 | -------------------------------------------------------------------------------- /module1/dist/1.7.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __assign = (this && this.__assign) || function () { 3 | __assign = Object.assign || function(t) { 4 | for (var s, i = 1, n = arguments.length; i < n; i++) { 5 | s = arguments[i]; 6 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) 7 | t[p] = s[p]; 8 | } 9 | return t; 10 | }; 11 | return __assign.apply(this, arguments); 12 | }; 13 | { 14 | // spread operator 15 | // rest oprator 16 | // destructuring 17 | //learn spread operatoe 18 | var bros1 = ["Mir", "Firoz", "Mizan"]; 19 | var bros2 = ["Tanmoy", "Nahid", "Rahat"]; 20 | bros1.push.apply(bros1, bros2); 21 | var mentors1 = { 22 | typescript: "Mezba", 23 | redux: "Mir", 24 | dbms: "Mizan", 25 | }; 26 | var mentors2 = { 27 | prisma: "Firoz", 28 | next: "Tanmoy", 29 | cloud: "Nahid", 30 | }; 31 | var mentorList = __assign(__assign({}, mentors1), mentors2); 32 | // learn rest opeartor 33 | var greetFriends = function () { 34 | // console.log(`Hi ${friend1} ${friend2} ${friend3}`); 35 | var friends = []; 36 | for (var _i = 0; _i < arguments.length; _i++) { 37 | friends[_i] = arguments[_i]; 38 | } 39 | friends.forEach(function (friend) { return console.log("Hi ".concat(friend)); }); 40 | }; 41 | greetFriends("Abul", "kabul", "babul", "ubul", "labul"); 42 | } 43 | -------------------------------------------------------------------------------- /module1/dist/1.8.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // destructuring 3 | var user = { 4 | id: 345, 5 | name: { 6 | firstName: "Mezbaul", 7 | middleName: "Abedin", 8 | lastName: "Persian", 9 | }, 10 | contactNo: "0170000000", 11 | address: "Uganda", 12 | }; 13 | var contactNo = user.contactNo, midName = user.name.middleName; 14 | // array destructuring 15 | var myFriends = ["chandler", "joey", "ross", "rachel", "monica", "phoebe"]; 16 | var bestFriend = myFriends[2], rest = myFriends.slice(3); 17 | -------------------------------------------------------------------------------- /module1/dist/1.9.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | { 3 | var student1 = { 4 | name: "Mezba", 5 | age: 50, 6 | gender: "male", 7 | contactNo: "0170000000", 8 | address: "ctg", 9 | }; 10 | var student2 = { 11 | name: "Mir", 12 | age: 40, 13 | gender: "male", 14 | address: "dhk", 15 | }; 16 | var student3 = { 17 | name: "Mir", 18 | age: 40, 19 | gender: "male", 20 | address: "dhk", 21 | }; 22 | var userName = "Persian"; 23 | var isAdmin = true; 24 | var add = function (num1, num2) { return num1 + num2; }; 25 | // 26 | } 27 | -------------------------------------------------------------------------------- /module1/dist/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var course = "Next level web development"; 3 | console.log(course); 4 | -------------------------------------------------------------------------------- /module1/dist/test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | -------------------------------------------------------------------------------- /module1/src/2.10.ts: -------------------------------------------------------------------------------- 1 | { 2 | // 3 | // union types 4 | 5 | // type FrontendDeveloper = 'fakibazDeveloper' | 'juniorDeveloper' 6 | // type FullstackDeveloper = 'frontendDeveloper' | 'expertDeveloper' 7 | 8 | // type Developer = FrontendDeveloper | FullstackDeveloper 9 | 10 | // const newDeveloper : FrontendDeveloper = 'juniorDeveloper' 11 | 12 | // type User ={ 13 | // name: string; 14 | // email?: string; 15 | // gender:"male"| "female"; 16 | // bloodGroup:"O+"|"A+"|"AB+" 17 | // } 18 | 19 | // const user1: User ={ 20 | // name:'persian', 21 | // gender:'male', 22 | // bloodGroup:'O+' 23 | // } 24 | 25 | type FrontendDeveloper = { 26 | skills: string[]; 27 | designation1: "Frontend Developer"; 28 | }; 29 | 30 | type BackendDeveloper = { 31 | skills: string[]; 32 | designation2: "Backend Developer"; 33 | }; 34 | 35 | type FullstackDeveloper = FrontendDeveloper & BackendDeveloper; 36 | 37 | const fullstackDeveloper: FullstackDeveloper = { 38 | skills: ["HTML", "CSS", "EXPRESS"], 39 | designation1: "Frontend Developer", 40 | designation2: "Backend Developer", 41 | }; 42 | 43 | // 44 | } 45 | -------------------------------------------------------------------------------- /module1/src/2.11.ts: -------------------------------------------------------------------------------- 1 | { 2 | // ternary operator || optional chaining || nullish coalescing operator 3 | 4 | const age: number = 18; 5 | 6 | if (age >= 18) { 7 | console.log("adult"); 8 | } else { 9 | console.log("not adult"); 10 | } 11 | 12 | const isAdult = age >= 18 ? "adult" : "not adult"; 13 | // console.log({ isAdult }); 14 | 15 | //nullish coalescing operator 16 | // null / undefined ---> decision making 17 | 18 | const isAuthenticated = ""; 19 | 20 | const result1 = isAuthenticated ?? "Guest"; 21 | const result2 = isAuthenticated ? isAuthenticated : "Guest"; 22 | console.log({ result1 }, { result2 }); 23 | 24 | type User = { 25 | name: string; 26 | address: { 27 | city: string; 28 | road: string; 29 | presentaddress: string; 30 | permanentAddress?: string; 31 | }; 32 | }; 33 | 34 | const user: User = { 35 | name: "Persian", 36 | address: { 37 | city: "ctg", 38 | road: "Awesome Road", 39 | presentaddress: "ctg town", 40 | }, 41 | }; 42 | 43 | const permanentAddress = 44 | user?.address?.permanentAddress ?? "No Permanent Address"; 45 | console.log({ permanentAddress }); 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /module1/src/2.12.ts: -------------------------------------------------------------------------------- 1 | { 2 | // nullable types / unknown types 3 | 4 | const searchName = (value: string | null) => { 5 | if (value) { 6 | console.log("Searching"); 7 | } else { 8 | console.log("There is nothing to search"); 9 | } 10 | }; 11 | searchName(null); 12 | 13 | // unknown typeof 14 | 15 | const getSpeedInMeterPerSecond = (value: unknown) => { 16 | if (typeof value === "number") { 17 | const convertedSpeed = (value * 1000) / 3600; 18 | console.log(`The speed is ${convertedSpeed} ms^-1`); 19 | } else if (typeof value === "string") { 20 | const [result, unit] = value.split(" "); 21 | const convertedSpeed = (parseFloat(result) * 1000) / 3600; 22 | console.log(`The speed is ${convertedSpeed} ms^-1`); 23 | } else { 24 | console.log("wrong input"); 25 | } 26 | }; 27 | getSpeedInMeterPerSecond(null); 28 | 29 | //never 30 | 31 | const throwError = (msg: string): never => { 32 | throw new Error(msg); 33 | }; 34 | 35 | throwError("mushkil se error hogaya"); 36 | 37 | // 38 | } 39 | -------------------------------------------------------------------------------- /module1/src/2.4.ts: -------------------------------------------------------------------------------- 1 | // { 2 | // // Basic Data Type 3 | 4 | // //string 5 | // let firstName: string = "mezba"; 6 | // //number 7 | // let roll: number = 123; 8 | // //boolean 9 | // let isAdmin: boolean = true; 10 | // // undefined 11 | // let x: undefined = undefined; 12 | // // null 13 | // let y: null = null; 14 | 15 | // let d: number; 16 | 17 | // d = 123; 18 | 19 | // // Array 20 | 21 | // let friends: string[] = ["rachel", "monica"]; 22 | 23 | // let eligibleRollList: number[] = [1, 3]; 24 | 25 | // eligibleRollList.push("dd"); 26 | 27 | // // tuple --> array --> order --> type of values 28 | 29 | // let coordinates: [number, number] = [1, 5]; 30 | 31 | // let ageName: [number, string, boolean] = [50, "Mr.X", true]; 32 | 33 | // ageName[0] = 67; 34 | // } 35 | -------------------------------------------------------------------------------- /module1/src/2.5.ts: -------------------------------------------------------------------------------- 1 | // { 2 | // // Reference Type --> Object 3 | 4 | // const user: { 5 | // readonly company: string; // type --> literal types 6 | // firstName: string; 7 | // middleName?: string; // optional type 8 | // lastName: string; 9 | // isMarried: boolean; 10 | // } = { 11 | // company: "Programming Hero", 12 | // firstName: "Mezbaul", 13 | // lastName: "Abedin", 14 | // isMarried: true, 15 | // }; 16 | 17 | // user.company = "PH"; 18 | // } 19 | -------------------------------------------------------------------------------- /module1/src/2.6.ts: -------------------------------------------------------------------------------- 1 | // { 2 | // //Learning function 3 | // // Normal Function 4 | // // Arrow Function 5 | 6 | // function add(num1: number, num2: number = 10): number { 7 | // return num1 + num2; 8 | // } 9 | 10 | // add(2, "2"); 11 | 12 | // const addArrow = (num1: number, num2: number): number => num1 + num2; 13 | 14 | // // object --> function --> method 15 | 16 | // const poorUser = { 17 | // name: "Mezba", 18 | // balance: 0, 19 | // addBalance(balance: number): string { 20 | // return `My new balance is : ${this.balance + balance}`; 21 | // }, 22 | // }; 23 | 24 | // const arr: number[] = [1, 4, 10]; 25 | 26 | // const newArray: number[] = arr.map((elem: number): number => elem * elem); 27 | // } 28 | -------------------------------------------------------------------------------- /module1/src/2.7.ts: -------------------------------------------------------------------------------- 1 | { 2 | // spread operator 3 | // rest oprator 4 | // destructuring 5 | 6 | //learn spread operatoe 7 | 8 | const bros1: string[] = ["Mir", "Firoz", "Mizan"]; 9 | const bros2: string[] = ["Tanmoy", "Nahid", "Rahat"]; 10 | bros1.push(...bros2); 11 | 12 | const mentors1 = { 13 | typescript: "Mezba", 14 | redux: "Mir", 15 | dbms: "Mizan", 16 | }; 17 | 18 | const mentors2 = { 19 | prisma: "Firoz", 20 | next: "Tanmoy", 21 | cloud: "Nahid", 22 | }; 23 | 24 | const mentorList = { 25 | ...mentors1, 26 | ...mentors2, 27 | }; 28 | 29 | // learn rest opeartor 30 | 31 | const greetFriends = (...friends: string[]) => { 32 | // console.log(`Hi ${friend1} ${friend2} ${friend3}`); 33 | 34 | friends.forEach((friend: string) => console.log(`Hi ${friend}`)); 35 | }; 36 | 37 | greetFriends("Abul", "kabul", "babul", "ubul", "labul"); 38 | } 39 | -------------------------------------------------------------------------------- /module1/src/2.8.ts: -------------------------------------------------------------------------------- 1 | // destructuring 2 | 3 | const user = { 4 | id: 345, 5 | name: { 6 | firstName: "Mezbaul", 7 | middleName: "Abedin", 8 | lastName: "Persian", 9 | }, 10 | contactNo: "0170000000", 11 | address: "Uganda", 12 | }; 13 | 14 | const { 15 | contactNo, 16 | name: { middleName: midName }, 17 | } = user; 18 | 19 | // array destructuring 20 | 21 | const myFriends = ["chandler", "joey", "ross", "rachel", "monica", "phoebe"]; 22 | 23 | const [, , bestFriend, ...rest] = myFriends; 24 | -------------------------------------------------------------------------------- /module1/src/2.9.ts: -------------------------------------------------------------------------------- 1 | { 2 | // Type Alias 3 | 4 | type Student = { 5 | name: string; 6 | age: number; 7 | contactNo?: string; 8 | gender: string; 9 | address: string; 10 | }; 11 | 12 | const student1: Student = { 13 | name: "Mezba", 14 | age: 50, 15 | gender: "male", 16 | contactNo: "0170000000", 17 | address: "ctg", 18 | }; 19 | 20 | const student2: Student = { 21 | name: "Mir", 22 | age: 40, 23 | gender: "male", 24 | address: "dhk", 25 | }; 26 | 27 | const student3: Student = { 28 | name: "Mir", 29 | age: 40, 30 | gender: "male", 31 | address: "dhk", 32 | }; 33 | 34 | type UserName = string; 35 | type IsAdmin = boolean; 36 | const userName: UserName = "Persian"; 37 | const isAdmin: IsAdmin = true; 38 | 39 | type Add = (num1: number, num2: number) => number; 40 | 41 | const add: Add = (num1, num2) => num1 + num2; 42 | 43 | // 44 | } 45 | -------------------------------------------------------------------------------- /module1/src/index.ts: -------------------------------------------------------------------------------- 1 | let course: string = "Next level web development"; 2 | console.log(course); 3 | -------------------------------------------------------------------------------- /module2/3.1.ts: -------------------------------------------------------------------------------- 1 | { 2 | // 3 | 4 | // type assertion 5 | let anything: any; 6 | 7 | anything = "Next Level Web Development"; 8 | 9 | anything = 222; 10 | 11 | // (anything as number). 12 | 13 | const kgToGm = (value: string | number): string | number | undefined => { 14 | if (typeof value === "string") { 15 | const convertedValue = parseFloat(value) * 1000; 16 | return `The converted value is : ${convertedValue}`; 17 | } 18 | if (typeof value === "number") { 19 | return value * 1000; 20 | } 21 | }; 22 | 23 | const result1 = kgToGm(1000) as number; 24 | const result2 = kgToGm("1000"); 25 | 26 | type CustomError = { 27 | message: string; 28 | }; 29 | 30 | try { 31 | } catch (error) { 32 | console.log((error as CustomError).message); 33 | } 34 | 35 | // 36 | } 37 | -------------------------------------------------------------------------------- /module2/3.10.ts: -------------------------------------------------------------------------------- 1 | { 2 | // mapped types 3 | 4 | const arrOfNumbers: number[] = [1, 4, 5]; 5 | 6 | // const arrOfStrings : string[] = ['1','4','5'] 7 | const arrOfStrings: string[] = arrOfNumbers.map((number) => 8 | number.toString() 9 | ); 10 | console.log(arrOfStrings); 11 | 12 | type AreaNumber = { 13 | height: number; 14 | width: number; 15 | }; 16 | 17 | type Height = AreaNumber["height"]; // look up type 18 | // type AreaString = { 19 | // height: string; 20 | // width: string 21 | // } 22 | // keyof AreaNumber => "height"|"width" 23 | 24 | // T => {height:string;width:number} 25 | // key => T["width"] 26 | type AreaString = { 27 | [key in keyof T]: T[key]; 28 | }; 29 | 30 | const area1: AreaString<{ height: string; width: number }> = { 31 | height: "100", 32 | width: 50, 33 | }; 34 | 35 | // 36 | } 37 | -------------------------------------------------------------------------------- /module2/3.11.ts: -------------------------------------------------------------------------------- 1 | { 2 | //utility types 3 | // Pick 4 | type Person = { 5 | name: string; 6 | age: number; 7 | email?: string; 8 | contactNo: string; 9 | }; 10 | 11 | type NameAge = Pick; 12 | 13 | // Omit 14 | type ContactInfo = Omit; 15 | 16 | // Required 17 | type PersonRequired = Required; 18 | 19 | // Partial 20 | type PersonPartial = Partial; 21 | 22 | // Readonly 23 | type PersonReadonly = Readonly; 24 | 25 | const person1: PersonReadonly = { 26 | name: "Mr. XY", 27 | age: 200, 28 | contactNo: "017", 29 | }; 30 | person1.name = "Mr. YZ"; 31 | 32 | // Record 33 | // type MyObj = { 34 | // a: string; 35 | // b: string; 36 | // }; 37 | 38 | type MyObj = Record; 39 | 40 | const EmptyObj: Record = {}; 41 | 42 | const obj1: MyObj = { 43 | a: "aa", 44 | b: "bb", 45 | c: "cc", 46 | d: "dd", 47 | e: 6, 48 | }; 49 | 50 | // 51 | } 52 | -------------------------------------------------------------------------------- /module2/3.2.ts: -------------------------------------------------------------------------------- 1 | { 2 | // interface 3 | 4 | type User1 = { 5 | name: string; 6 | age: number; 7 | }; 8 | 9 | interface User2 { 10 | name: string; 11 | age: number; 12 | } 13 | 14 | type UserWithRole1 = User1 & { role: string }; 15 | 16 | interface UserWithRole2 extends User1 { 17 | role: string; 18 | } 19 | 20 | const user1: UserWithRole2 = { 21 | name: "Persian", 22 | age: 100, 23 | role: "manager", 24 | }; 25 | 26 | type rollNumber = number; 27 | 28 | // js --> object , array-> object function -> object 29 | 30 | type Roll1 = number[]; 31 | 32 | interface Roll2 { 33 | [index : number ] : number 34 | } 35 | 36 | const rollNumber1: Roll2 = [1,2,3] 37 | 0 1 2 --> number type 38 | 39 | 40 | type Add1 = (num1: number,num2:number)=> number 41 | 42 | interface Add2 { 43 | (num1: number,num2:number) : number 44 | } 45 | 46 | const add: Add2 = (num1 , num2 )=> num1+num2 47 | 48 | // 49 | } 50 | -------------------------------------------------------------------------------- /module2/3.3.ts: -------------------------------------------------------------------------------- 1 | { 2 | // generic type 3 | 4 | type GenericArray = Array; 5 | 6 | // const rollNumbers: number[] = [3, 6, 8]; 7 | const rollNumbers: GenericArray = [3, 6, 8]; 8 | 9 | // const mentors: string[] = ["Mr. X", "Mr. Y", "Mr. Z"]; 10 | const mentors: GenericArray = ["Mr. X", "Mr. Y", "Mr. Z"]; 11 | 12 | // const boolArray: boolean[] = [true, false, true]; 13 | const boolArray: GenericArray = [true, false, true]; 14 | 15 | interface User { 16 | name: string; 17 | age: number; 18 | } 19 | 20 | const user: GenericArray = [ 21 | { 22 | name: "Mezba", 23 | age: 100, 24 | }, 25 | { 26 | name: "Jhankar Mahbub", 27 | age: 110, 28 | }, 29 | ]; 30 | 31 | const add = (x: number, y: number) => x + y; 32 | 33 | add(30, 20); 34 | 35 | //generic tuple 36 | 37 | type GenericTuple = [X, Y]; 38 | 39 | const manush: GenericTuple = ["Mr. X", "Mr. Y"]; 40 | 41 | const UserWithID: GenericTuple = [ 42 | 1234, 43 | { name: "persian", email: "a@gmail.com" }, 44 | ]; 45 | } 46 | -------------------------------------------------------------------------------- /module2/3.4.ts: -------------------------------------------------------------------------------- 1 | { 2 | // intercae - generic 3 | 4 | interface Developer { 5 | name: string; 6 | computer: { 7 | brand: string; 8 | model: string; 9 | releaseYear: number; 10 | }; 11 | smartWatch: T; 12 | bike?: X; 13 | } 14 | 15 | type EmilabWatch = { 16 | brand: string; 17 | model: string; 18 | display: string; 19 | }; 20 | 21 | const poorDeveloper: Developer = { 22 | name: "Persian", 23 | computer: { 24 | brand: "Asus", 25 | model: "X-255UR", 26 | releaseYear: 2013, 27 | }, 28 | smartWatch: { 29 | brand: "Emilab", 30 | model: "kw66", 31 | display: "OLED", 32 | }, 33 | }; 34 | 35 | interface AppleWatch { 36 | brand: string; 37 | model: string; 38 | heartTrack: boolean; 39 | sleepTrack: boolean; 40 | } 41 | 42 | interface YamahaBike { 43 | model: string; 44 | engineCapacity: string; 45 | } 46 | 47 | const richDeveloper: Developer = { 48 | name: "Rich Dev", 49 | computer: { 50 | brand: "HP", 51 | model: "X-25UR", 52 | releaseYear: 2018, 53 | }, 54 | smartWatch: { 55 | brand: "Apple Watch", 56 | model: "Something", 57 | heartTrack: true, 58 | sleepTrack: true, 59 | }, 60 | bike: { 61 | model: "Yamaha", 62 | engineCapacity: "100cc", 63 | }, 64 | }; 65 | 66 | // 67 | } 68 | -------------------------------------------------------------------------------- /module2/3.5.ts: -------------------------------------------------------------------------------- 1 | { 2 | // function with generics 3 | 4 | const createArray = (param: string): string[] => { 5 | return [param]; 6 | }; 7 | 8 | const createArrayWithGeneric = (param: T): T[] => { 9 | return [param]; 10 | }; 11 | 12 | const res1 = createArray("Bangladesh"); 13 | const resGeneric = createArrayWithGeneric("Bangladesh"); 14 | 15 | type User = { id: number; name: string }; 16 | 17 | const resGenericObj = createArrayWithGeneric({ 18 | id: 222, 19 | name: "Mr. Pashan", 20 | }); 21 | 22 | const createArrayWithTuple = (param1: T, param2: Q): [T, Q] => { 23 | return [param1, param2]; 24 | }; 25 | 26 | const res10 = createArrayWithTuple("Bangladesh", 222); 27 | const res11 = createArrayWithTuple("Bangladesh", { 28 | name: "Asia", 29 | }); 30 | 31 | const addCourseToStudent = (student: T) => { 32 | const course = "Next Level Web Development"; 33 | return { 34 | ...student, 35 | course, 36 | }; 37 | }; 38 | 39 | const student1 = addCourseToStudent({ 40 | name: "Mr X", 41 | email: "x@gmail.com", 42 | devType: "NLWD", 43 | }); 44 | 45 | const student2 = addCourseToStudent({ 46 | name: "Mr Y", 47 | email: "y@gmail.com", 48 | hasWatch: "Apple Watch", 49 | }); 50 | 51 | // 52 | } 53 | -------------------------------------------------------------------------------- /module2/3.6.ts: -------------------------------------------------------------------------------- 1 | { 2 | // constraints 3 | 4 | const addCourseToStudent = < 5 | T extends { id: number; name: string; email: string } 6 | >( 7 | student: T 8 | ) => { 9 | const course = "Next Level Web Development"; 10 | return { 11 | ...student, 12 | course, 13 | }; 14 | }; 15 | 16 | const student3 = addCourseToStudent({ 17 | id: 44, 18 | name: "Mr. Z", 19 | email: "z@gmail.com", 20 | emni: "emni", 21 | }); 22 | 23 | const student1 = addCourseToStudent<{ 24 | id: number; 25 | name: string; 26 | email: string; 27 | devType: string; 28 | }>({ 29 | id: 222, 30 | name: "Mr X", 31 | email: "x@gmail.com", 32 | devType: "NLWD", 33 | }); 34 | 35 | const student2 = addCourseToStudent({ 36 | id: 333, 37 | name: "Mr Y", 38 | email: "y@gmail.com", 39 | hasWatch: "Apple Watch", 40 | }); 41 | 42 | // 43 | } 44 | -------------------------------------------------------------------------------- /module2/3.7.ts: -------------------------------------------------------------------------------- 1 | { 2 | // generic constraint with keyof operator 3 | type Vehicle = { 4 | bike: string; 5 | car: string; 6 | ship: string; 7 | }; 8 | 9 | type Owner = "bike" | "car" | "ship"; // manually 10 | type Owner2 = keyof Vehicle; 11 | 12 | const getPropertyValue = (obj: X, key: Y) => { 13 | return obj[key]; 14 | }; 15 | 16 | const user = { 17 | name: "Mr. persian", 18 | age: 26, 19 | address: "ctg", 20 | }; 21 | 22 | const car = { 23 | model: "Toyota 100", 24 | year: 200, 25 | }; 26 | 27 | const result1 = getPropertyValue(car, "sjs"); 28 | 29 | // obj[key] 26 30 | 31 | // 32 | } 33 | -------------------------------------------------------------------------------- /module2/3.8.ts: -------------------------------------------------------------------------------- 1 | { 2 | // promise 3 | 4 | type Todo = { 5 | id: number; 6 | userId: number; 7 | title: string; 8 | completed: boolean; 9 | }; 10 | 11 | const getTodo = async (): Promise => { 12 | const response = await fetch( 13 | "https://jsonplaceholder.typicode.com/todos/1" 14 | ); 15 | 16 | const data = await response.json(); 17 | return data; 18 | // console.log(data); 19 | }; 20 | 21 | getTodo(); 22 | 23 | type Something = { something: string }; 24 | 25 | // simulate 26 | const createPromise = (): Promise => { 27 | return new Promise((resolve, reject) => { 28 | const data: Something = { something: "something" }; 29 | if (data) { 30 | resolve(data); 31 | } else { 32 | reject("failed to load data"); 33 | } 34 | }); 35 | }; 36 | 37 | // calling create promise function 38 | const showData = async (): Promise => { 39 | const data: Something = await createPromise(); 40 | return data; 41 | // console.log(data); 42 | }; 43 | 44 | showData(); 45 | 46 | // 47 | } 48 | -------------------------------------------------------------------------------- /module2/3.9.ts: -------------------------------------------------------------------------------- 1 | { 2 | //conditional type 3 | 4 | type a1 = number; 5 | type b1 = string; 6 | 7 | type x = a1 extends null ? true : false; // conditional type 8 | 9 | type y = a1 extends null ? true : b1 extends undefined ? undefined : any; 10 | 11 | type Sheikh = { 12 | bike: string; 13 | car: string; 14 | ship: string; 15 | plane: string; 16 | }; 17 | 18 | //keyof Sheikh "bike" | "car" | "ship" 19 | 20 | // car ase kina / bike ase kina / ship kina / tractor ase kina 21 | type CheckVehicle = T extends keyof Sheikh ? true : false; 22 | 23 | type HasPlane = CheckVehicle<"plane">; 24 | // 25 | } 26 | -------------------------------------------------------------------------------- /module3/4.1.ts: -------------------------------------------------------------------------------- 1 | { 2 | // oop - class 3 | 4 | class Animal { 5 | constructor( 6 | public name: string, 7 | public species: string, 8 | public sound: string 9 | ) {} 10 | 11 | makeSound() { 12 | console.log(`The ${this.name} says ${this.sound}`); 13 | } 14 | } 15 | 16 | const dog = new Animal("German Shepard Bhai", "dog", "Ghew Ghew"); 17 | const cat = new Animal("Persian bhai", "cat", "meaw meaw"); 18 | 19 | cat.makeSound(); 20 | 21 | // 22 | } 23 | -------------------------------------------------------------------------------- /module3/4.10.ts: -------------------------------------------------------------------------------- 1 | { 2 | // access modifiers 3 | class BankAccount { 4 | public readonly id: number; 5 | public name: string; 6 | protected _balance: number; 7 | 8 | constructor(id: number, name: string, balance: number) { 9 | this.id = id; 10 | this.name = name; 11 | this._balance = balance; 12 | } 13 | 14 | public addDeposit(amount: number) { 15 | this._balance = this._balance + amount; 16 | } 17 | 18 | private getBalance() { 19 | return this._balance; 20 | } 21 | 22 | getHiddenMethod(){ 23 | return this.getBalance() 24 | } 25 | } 26 | 27 | class StudentAccount extends BankAccount{ 28 | test(){ 29 | this. 30 | } 31 | } 32 | 33 | const goribManusherAccount = new BankAccount(111, "Mr. gorib", 20); 34 | // goribManusherAccount.balance = 0; 35 | goribManusherAccount.addDeposit(20); 36 | const myBalance = goribManusherAccount.getBalance(); 37 | console.log(myBalance); 38 | 39 | goribManusherAccount. 40 | 41 | // 42 | } 43 | -------------------------------------------------------------------------------- /module3/4.2.ts: -------------------------------------------------------------------------------- 1 | { 2 | // oop - inheritence 3 | class Person { 4 | name: string; 5 | age: number; 6 | address: string; 7 | 8 | constructor(name: string, age: number, address: string) { 9 | this.name = name; 10 | this.age = age; 11 | this.address = address; 12 | } 13 | getSleep(numOfHours: number) { 14 | console.log(`${this.name} will sleep for ${numOfHours}`); 15 | } 16 | } 17 | 18 | 19 | class Student extends Person { 20 | constructor(name: string, age: number, address: string) { 21 | super(name, age, address) 22 | } 23 | 24 | } 25 | 26 | const student1 = new Student("Mr. student", 20, "Uganda"); 27 | student1. 28 | 29 | 30 | class Teacher extends Person{ 31 | designation: string 32 | 33 | constructor(name: string, age: number, address: string,designation: string) { 34 | super(name, age , address) 35 | this.designation = designation 36 | } 37 | 38 | takeClass(numOfClass: number){ 39 | console.log(`${this.name} will take ${numOfClass}`); 40 | } 41 | } 42 | 43 | const teacher = new Teacher("Mr. teacher", 40, "Uganda","professor"); 44 | teacher. 45 | // 46 | } 47 | -------------------------------------------------------------------------------- /module3/4.3.ts: -------------------------------------------------------------------------------- 1 | { 2 | // type guards 3 | 4 | // typeof --> type guard 5 | 6 | type Alphaneumeric = string | number; 7 | 8 | const add = (param1: Alphaneumeric, param2: Alphaneumeric): Alphaneumeric => { 9 | if (typeof param1 === "number" && typeof param2 === "number") { 10 | return param1 + param2; 11 | } else { 12 | return param1.toString() + param2.toString(); 13 | } 14 | }; 15 | 16 | const result1 = add("2", "3"); 17 | console.log(result1); 18 | 19 | // in guard 20 | type NormalUser = { 21 | name: string; 22 | }; 23 | 24 | type AdminUser = { 25 | name: string; 26 | role: "admin"; 27 | }; 28 | 29 | const getUser = (user: NormalUser | AdminUser) => { 30 | if ("role" in user) { 31 | console.log(`My name is ${user.name} and my role is ${user.role}`); 32 | } else { 33 | console.log(`My name is ${user.name}`); 34 | } 35 | }; 36 | 37 | const normalUser: NormalUser = { 38 | name: "Mr. Normal Bhai", 39 | }; 40 | const adminUser: AdminUser = { 41 | name: "Mr. Admin Bhai", 42 | role: "admin", 43 | }; 44 | 45 | getUser(adminUser); 46 | 47 | // 48 | } 49 | -------------------------------------------------------------------------------- /module3/4.4.ts: -------------------------------------------------------------------------------- 1 | { 2 | // instanceof guard 3 | class Animal { 4 | name: string; 5 | species: string; 6 | 7 | constructor(name: string, species: string) { 8 | this.name = name; 9 | this.species = species; 10 | } 11 | 12 | makeSound() { 13 | console.log("I am making sound"); 14 | } 15 | } 16 | 17 | class Dog extends Animal { 18 | constructor(name: string, species: string) { 19 | super(name, species); 20 | } 21 | makeBark() { 22 | console.log("I am barking"); 23 | } 24 | } 25 | 26 | class Cat extends Animal { 27 | constructor(name: string, species: string) { 28 | super(name, species); 29 | } 30 | makeMeaw() { 31 | console.log("I am mewaing"); 32 | } 33 | } 34 | 35 | // smart way tge handle korar jnne chaile amra function bebohar krte pari 36 | const isDog = (animal: Animal): animal is Dog => { 37 | return animal instanceof Dog; 38 | }; 39 | 40 | const isCat = (animal: Animal): animal is Cat => { 41 | return animal instanceof Cat; 42 | }; 43 | 44 | const getAnimal = (animal: Animal) => { 45 | if (isDog(animal)) { 46 | animal.makeBark(); 47 | } else if (isCat(animal)) { 48 | animal.makeMeaw(); 49 | } else { 50 | animal.makeSound(); 51 | } 52 | }; 53 | 54 | const dog = new Dog("Dog Bhai", "dog"); 55 | const cat = new Cat("Cat Bhai", "cat"); 56 | 57 | getAnimal(cat); 58 | 59 | // 60 | } 61 | -------------------------------------------------------------------------------- /module3/4.5.ts: -------------------------------------------------------------------------------- 1 | { 2 | // access modifiers 3 | class BankAccount { 4 | public readonly id: number; 5 | public name: string; 6 | private _balance: number; 7 | 8 | constructor(id: number, name: string, balance: number) { 9 | this.id = id; 10 | this.name = name; 11 | this._balance = balance; 12 | } 13 | 14 | public addDeposit(amount: number) { 15 | this._balance = this._balance + amount; 16 | } 17 | 18 | public getBalance() { 19 | return this._balance; 20 | } 21 | } 22 | 23 | class StudentAccount extends BankAccount{ 24 | test(){ 25 | this. 26 | } 27 | } 28 | 29 | const goribManusherAccount = new BankAccount(111, "Mr. gorib", 20); 30 | // goribManusherAccount.balance = 0; 31 | goribManusherAccount.addDeposit(20); 32 | const myBalance = goribManusherAccount.getBalance(); 33 | console.log(myBalance); 34 | 35 | // 36 | } 37 | -------------------------------------------------------------------------------- /module3/4.6.ts: -------------------------------------------------------------------------------- 1 | { 2 | // getter and setter 3 | class BankAccount { 4 | public readonly id: number; 5 | public name: string; 6 | protected _balance: number; 7 | 8 | constructor(id: number, name: string, balance: number) { 9 | this.id = id; 10 | this.name = name; 11 | this._balance = balance; 12 | } 13 | 14 | set deposit(amount: number) { 15 | this._balance = this.balance + amount; 16 | } 17 | // public addDeposit(amount: number) { 18 | // this._balance = this._balance + amount; 19 | // } 20 | 21 | //getter 22 | get balance() { 23 | return this._balance; 24 | } 25 | // public getBalance() { 26 | // return this._balance; 27 | // } 28 | } 29 | 30 | const goribManusherAccount = new BankAccount(111, "Mr. gorib", 50); 31 | 32 | // goribManusherAccount.deposit = 0; 33 | // goribManusherAccount.addDeposit(20); // function call korte hsse 34 | goribManusherAccount.deposit = 50; 35 | // const myBalance = goribManusherAccount.getBalance(); // function call korte hsse 36 | 37 | const myBalance = goribManusherAccount.balance; // property er mto kore 38 | console.log(myBalance); 39 | 40 | // 41 | } 42 | -------------------------------------------------------------------------------- /module3/4.7.ts: -------------------------------------------------------------------------------- 1 | { 2 | // static 3 | class Counter { 4 | static count: number = 0; 5 | 6 | static increment() { 7 | return (Counter.count = Counter.count + 1); 8 | } 9 | 10 | static decrement() { 11 | return (Counter.count = Counter.count - 1); 12 | } 13 | } 14 | 15 | // const instance1 = new Counter(); 16 | console.log(Counter.increment()); // 1 -> different memory 17 | // 1 -> different memory 18 | 19 | // const instance2 = new Counter(); 20 | console.log(Counter.increment()); // 1 --> different memory 21 | // 1 --> different memory 22 | 23 | // const instance3 = new Counter(); 24 | console.log(Counter.increment()); 25 | // 26 | } 27 | -------------------------------------------------------------------------------- /module3/4.8.ts: -------------------------------------------------------------------------------- 1 | { 2 | // polymorphisom 3 | 4 | class Person { 5 | getSleep() { 6 | console.log(`I am sleeping for 8 hours per day`); 7 | } 8 | } 9 | 10 | class Student extends Person { 11 | getSleep() { 12 | console.log(`I am sleeping for 7 hours per day`); 13 | } 14 | } 15 | 16 | class Developer extends Person { 17 | getSleep() { 18 | console.log(`I am sleeping for 6 hours per day`); 19 | } 20 | } 21 | 22 | const getSleepingHours = (param: Person) => { 23 | param.getSleep(); 24 | }; 25 | 26 | const person1 = new Person(); 27 | const person2 = new Student(); 28 | const person3 = new Developer(); 29 | 30 | getSleepingHours(person1); 31 | getSleepingHours(person2); 32 | getSleepingHours(person3); 33 | 34 | class Shape { 35 | getArea(): number { 36 | return 0; 37 | } 38 | } 39 | 40 | // pi* r* r 41 | class Circle extends Shape { 42 | radius: number; 43 | constructor(radius: number) { 44 | super(); 45 | this.radius = radius; 46 | } 47 | 48 | getArea(): number { 49 | return Math.PI * this.radius * this.radius; 50 | } 51 | } 52 | 53 | // height * width 54 | class Reactangle extends Shape { 55 | height: number; 56 | width: number; 57 | 58 | constructor(height: number, width: number) { 59 | super(); 60 | this.height = height; 61 | this.width = width; 62 | } 63 | 64 | getArea(): number { 65 | return this.height * this.width; 66 | } 67 | } 68 | 69 | const getShapeArea = (param: Shape) => { 70 | console.log(param.getArea()); 71 | }; 72 | 73 | const shape1 = new Shape(); 74 | const shape2 = new Circle(10); 75 | const shape3 = new Reactangle(10, 20); 76 | 77 | getShapeArea(shape3); 78 | 79 | // 80 | } 81 | -------------------------------------------------------------------------------- /module3/4.9.ts: -------------------------------------------------------------------------------- 1 | { 2 | // abstraction : 1. interface 2. abstract 3 | 4 | // idea 5 | interface Vehicle1 { 6 | startEngine(): void; 7 | stopEngine(): void; 8 | move(): void; 9 | } 10 | 11 | // real implementation 12 | class Car1 implements Vehicle1 { 13 | startEngine(): void { 14 | console.log(`I am starting the car engine`); 15 | } 16 | stopEngine(): void { 17 | console.log("I am stopping the car engine"); 18 | } 19 | move(): void { 20 | console.log(`I am moving the car`); 21 | } 22 | test() { 23 | console.log(`I am just testing`); 24 | } 25 | } 26 | 27 | const toyotaCar = new Car1(); 28 | toyotaCar.startEngine(); 29 | 30 | // abstract class 31 | 32 | // idea 33 | abstract class Car2 { 34 | abstract startEngine(): void; 35 | abstract stopEngine(): void; 36 | abstract move(): void; 37 | test() { 38 | console.log(`I am just testing`); 39 | } 40 | } 41 | 42 | class ToyotaCar extends Car2 { 43 | startEngine(): void { 44 | console.log("I am starting the car engine"); 45 | } 46 | stopEngine(): void { 47 | console.log("I am stopping the car engine"); 48 | } 49 | move(): void { 50 | console.log("I am moving the car"); 51 | } 52 | } 53 | 54 | // const hondaCar = new Car2(); 55 | // hondaCar.startEngine(); 56 | 57 | // 58 | } 59 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "ES6", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "commonjs", /* Specify what module code is generated. */ 29 | "rootDir": "./module1/src/", /* Specify the root folder within your source files. */ 30 | // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | // "resolveJsonModule": true, /* Enable importing .json files. */ 43 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 53 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | "outDir": "./module1/dist", /* Specify an output folder for all emitted files. */ 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 83 | 84 | /* Type Checking */ 85 | "strict": true, /* Enable all strict type-checking options. */ 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | } 109 | } 110 | --------------------------------------------------------------------------------