Question

This is typescript. I keep getting this error Parameter 'x' implicitly has an 'any' type, but...

This is typescript. I keep getting this error Parameter 'x' implicitly has an 'any' type, but a better type may be inferred from usage.ts(7044) .

class mycalculation {

    x: number = 1;

    y: number;

     add(x, y) {

         

        

        return x + y;

        


     }

    

    }

    const mycal = new mycalculation();

    const output = mycal.add(1,2);

I keep getting this error

Homework Answers

Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new typescript file with name "samp.ts" is created, which contains following code.

samp.ts :

//class

class mycalculation {

x: number = 1;

y: number;

add(x, y) { //function

return x + y;

}

}

//object of class

const mycal = new mycalculation();

//call method with class object

const output = mycal.add(1,2);

console.log("Adition is "+output);//print output

======================================================

Output : Compile and Run samp.ts to get the screen as shown below

Screen 1 :samp.ts

  • use command tsc samp.ts the typescript will be transpilled into javascript and the run javascript file using
  • command node samp.js then will get the screen as shown below

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Keep getting error that says: Array type 'char [26]' is not assignable this is in header...
Keep getting error that says: Array type 'char [26]' is not assignable this is in header file: char map [bigRow][bigComlum]; const int bigRow = 26; const int bigComlum = 24; this is in cpp file: map = new char [1]; map[0] = new char [1]; I really don't know how to fix this, my objective is to make a 1x1 grid with the symbol = 'x'. I'm not sure if the header file is correct, pleas help!
Here is my java code, I keep getting this error and I do not know how...
Here is my java code, I keep getting this error and I do not know how to fix it: PigLatin.java:3: error: class Main is public, should be declared in a file named Main.java public class Main { ^ import java.io.*; public class Main { private static BufferedReader buf = new BufferedReader( new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { String english = getString(); String translated = translate(english); System.out.println(translated); } private static String translate(String s) { String latin =...
I am not sure what I am doing wrong in this coding. I keep getting this...
I am not sure what I am doing wrong in this coding. I keep getting this error. I tried to change it to Circle2D.java but it still comes an error: Compiler error: class Circle2D is public, should be declared in a file named Circle2D.java public class Circle2D { public class Exercise10_11 { public static void main(String[] args) {     Circle2D c1 = new Circle2D(2, 2, 5.5);     System.out.println("area: " + c1.getArea());     System.out.println("perimeter: " + c1.getPerimeter());     System.out.println("contains(3, 3): "...
I'm not sure how to fix my code I keep getting an error with rhs.begin. I...
I'm not sure how to fix my code I keep getting an error with rhs.begin. I linked the header file and the test file, THESE TWO CANNOT be changed they have absolutely no errors in them. To clarify I ONLY need help with the copy constructor part. /* ~~~~~~~~~~~~list.cpp~~~~~~~~~~~~~~~*/ #include #include "list.h" using namespace std; Node::Node(string element) { data = element; previous = nullptr; next = nullptr; } List::List() { first = nullptr; last = nullptr; } List::List(const List& rhs)//...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 565 Error 2 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 761 I need this code to COMPILE and RUN, but I cannot get rid of this error. Please Help!! #include #include #include #include using namespace std; enum contactGroupType {// used in extPersonType FAMILY, FRIEND, BUSINESS, UNFILLED }; class addressType { private:...
MATLAB** I'm not sure what I'm doing wrong writing out my equation. I keep getting an...
MATLAB** I'm not sure what I'm doing wrong writing out my equation. I keep getting an error. It has something to do with the line with the function written out. Here's what I have: %3.2 clc clear close all %plot ?(?,?)=?(1+sin?), as a 3D plot on the domain ?∈[−8,8], ?∈[−8,8]. x=[-8:8]; y=[-8,8]; z=x(sin(y)+1); plot3(x,y,z) title('Plot 3.2')
This is an example out of my text which I copied directly but am getting an...
This is an example out of my text which I copied directly but am getting an error every iteration and am unsure how to correct it. The error is " the condition has length > 1 and only the first element will be used" and my code is: f <- function(x, sigma) { if (any(x < 0)) return(0) stopifnot(sigma > 0) return((x/sigma^2)*exp(-x^2 / (s*sigma^2))) } xt <- x[i-1] y <- rchisq(1, df = xt) m <- 10000 sigma <- 4...
I am stuck on these problems and need a explanation as to why i keep getting...
I am stuck on these problems and need a explanation as to why i keep getting them wrong/ what the answer is H0:  1 -  2= 0 Ha:  1 -  2≠ 0 The following results are from independent samples taken from two populations. Sample 1 Sample 2 n 1 = 35 n 2 = 40 x 1 = 13.6 x 2 = 10.1 s 1 = 5.8 s 2 = 8.2 a. What is the value of the test statistic (to 2 decimals)? b....
What's wrong with this code? #Java Why I am getting error in : int BusCompare =...
What's wrong with this code? #Java Why I am getting error in : int BusCompare = o1.numberOfBusinesses.compareTo(o2.numberOfBusinesses); public class TypeComparator implements Comparator<Type> { @Override public int compare(Type o1, Type o2) { // return o1.name.compareTo(o2.name); int NameCompare = o1.name.compareTo(o2.name); int BusCompare = o1.numberOfBusinesses.compareTo(o2.numberOfBusinesses); // 2-level comparison using if-else block if (NameCompare == 0) { return ((BusCompare == 0) ? NameCompare : BusCompare); } else { return NameCompare; } } } public class Type implements Comparable<Type> { int id; String name; int...
Please show formulas in Excel or work - My formulas keep getting an Error and I...
Please show formulas in Excel or work - My formulas keep getting an Error and I don't know what I am doing wrong. You want to compare two separate retirement savings​ scenarios: (A) and​ (B). In scenario​ (A) you start​ immediately, contribute for a few​ years, but then stop contributing.​ However, you leave the accumulated savings to compound until retirement. In scenario​(B) you start later​ (after the end of savings in scenario​ A) and contribute all the way to retirement....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT