From 5d865f7c3c022a9bd3240e5e864d22272c4e58cf Mon Sep 17 00:00:00 2001 From: Ahsan2001 Date: Fri, 11 Aug 2023 18:04:09 -0700 Subject: [PATCH] completed namespace topics --- Namespaces/index.js | 35 +++++++++++++++++++++++++++++++++++ Namespaces/index.ts | 19 +++++++++++++++++++ Namespaces/utils.js | 30 ++++++++++++++++++++++++++++++ Namespaces/utils.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 Namespaces/index.js create mode 100644 Namespaces/index.ts create mode 100644 Namespaces/utils.js create mode 100644 Namespaces/utils.ts diff --git a/Namespaces/index.js b/Namespaces/index.js new file mode 100644 index 0000000..8c6f7be --- /dev/null +++ b/Namespaces/index.js @@ -0,0 +1,35 @@ +/// +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var App; +(function (App) { + var Detail = /** @class */ (function (_super) { + __extends(Detail, _super); + function Detail() { + return _super !== null && _super.apply(this, arguments) || this; + } + Detail.prototype.getName = function () { + console.log("name is ".concat(this.name)); + }; + Detail.prototype.bio = function () { + return "Name: ".concat(this.getName(), " "); + }; + return Detail; + }(Bio.Name)); + App.Detail = Detail; + var a = new App.Detail("Ahsan"); + console.log(a.bio()); +})(App || (App = {})); diff --git a/Namespaces/index.ts b/Namespaces/index.ts new file mode 100644 index 0000000..e8f9c48 --- /dev/null +++ b/Namespaces/index.ts @@ -0,0 +1,19 @@ +/// + +namespace App { + + export class Detail extends Bio.Name implements Bio.Data { + + getName() { + console.log(`name is ${this.name}`) + } + + + bio(): string { + return `Name: ${this.getName()} `; + } + } + + const a = new App.Detail("Ahsan"); + console.log(a.bio()); +} diff --git a/Namespaces/utils.js b/Namespaces/utils.js new file mode 100644 index 0000000..7fa2561 --- /dev/null +++ b/Namespaces/utils.js @@ -0,0 +1,30 @@ +var Bio; +(function (Bio) { + var Name = /** @class */ (function () { + function Name(name) { + this.name = name; + } + return Name; + }()); + Bio.Name = Name; + var FatherName = /** @class */ (function () { + function FatherName(name) { + this.name = name; + } + FatherName.prototype.getFatherName = function () { + console.log("father name is ".concat(this.name)); + }; + return FatherName; + }()); + Bio.FatherName = FatherName; + var Age = /** @class */ (function () { + function Age(age) { + this.age = age; + } + Age.prototype.getAge = function () { + console.log("age is ".concat(this.age)); + }; + return Age; + }()); + Bio.Age = Age; +})(Bio || (Bio = {})); diff --git a/Namespaces/utils.ts b/Namespaces/utils.ts new file mode 100644 index 0000000..14c2a52 --- /dev/null +++ b/Namespaces/utils.ts @@ -0,0 +1,43 @@ + +namespace Bio { + export class Name { + protected name: string; + + constructor (name: string){ + this.name = name + } + + + } + + + export class FatherName { + protected name: string; + + constructor (name: string){ + this.name = name + } + + getFatherName() { + console.log(`father name is ${this.name}`) + } + } + + export class Age { + protected age: number; + + constructor (age: number){ + this.age = age + } + + getAge() { + console.log(`age is ${this.age}`) + } + } + + + export interface Data { + bio(): string; + } + +} \ No newline at end of file