Browse Source

Change address.ts and location.ts value parameter type from any to unknown

Lucas de Souza 4 years ago
parent
commit
1e7082245b
2 changed files with 14 additions and 14 deletions
  1. 3 3
      js/memory/address.ts
  2. 11 11
      js/memory/location.ts

+ 3 - 3
js/memory/address.ts

@@ -1,14 +1,14 @@
 export class Address {
 
   public id: number;
-  public value: any;
+  public value: unknown;
 
   /**
    * 
    * @param {Number} id the address id
-   * @param {*} value the value stored at this address
+   * @param {never} value the value stored at this address
    */
-  constructor (id: number, value: any) {
+  constructor (id: number, value: unknown) {
     this.id = id;
     this.value = value;
   }

+ 11 - 11
js/memory/location.ts

@@ -13,10 +13,10 @@ class LocationHolder {
 
   /**
    * 
-   * @param {*} value the value to be allocated
-   * @returns {Number} - the address id
+   * @param {never} value the value to be allocated
+   * @returns {number} - the address id
    */
-  allocate (value:any) : number {
+  allocate (value: unknown): number {
     const id = this.address_id;
     // console.log("Allocation address "+ id);
     const address = new Address(id, value);
@@ -27,9 +27,9 @@ class LocationHolder {
 
   /**
    * 
-   * @param {Number} id 
+   * @param {number} id 
    */
-  deallocate (id: number) : boolean {
+  deallocate (id: number): boolean {
     const index = this.findIndex(id);
     // console.log("Deallocation address "+ id);
     if(index !== -1) {
@@ -41,7 +41,7 @@ class LocationHolder {
 
   /**
    * 
-   * @param {Number} id 
+   * @param {number} id 
    * @returns {Address} the address identified by id
    */
   find (id: number): Address | undefined {
@@ -68,10 +68,10 @@ class LocationHolder {
 
   /**
    * 
-   * @param {Number} id address id
-   * @returns {Number} the index of the address identified by id
+   * @param {number} id address id
+   * @returns {number} the index of the address identified by id
    */
-  findIndex (id: number) : number {
+  findIndex (id: number): number {
     let beg = 0
     let end = this.data.length;
     while (beg < end) {
@@ -88,7 +88,7 @@ class LocationHolder {
     return -1;
   }
 
-  updateAddress (id: number, value: any): void {
+  updateAddress (id: number, value: unknown): void {
     const index = this.findIndex(id);
     if(index === -1) {
       throw new Error("Invalid address..." + id);
@@ -96,7 +96,7 @@ class LocationHolder {
     this.data[index].value = value;
   }
 
-  clear () {
+  clear (): void {
     for (let i = 0; i < this.data.length; i += 1) {
       delete this.data[i];
     }