Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

es6.d.ts has incorrect signature for console.log #4755

Closed
bootstraponline opened this issue Sep 12, 2015 · 5 comments
Closed

es6.d.ts has incorrect signature for console.log #4755

bootstraponline opened this issue Sep 12, 2015 · 5 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript

Comments

@bootstraponline
Copy link
Contributor

The default signature for console.log is wrong.

log(message?: any, ...optionalParams: any[]): void;

See this code example:

function puts(...optionalParams: any[]): void {
  console.log.apply(this, arguments); // no error

  // Supplied parameters do not match any signature of call target.
  // Method Console.log(message?: any, ...optionalParams: any[]): void;
  console.log(...arguments); // see error above
}

If I update the signature to log(...optionalParams: any[]): void; then it works.

@mhegazy mhegazy added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Sep 12, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Sep 12, 2015

until this is fixed, you can explicitly add the overload to one of your files:

interface Console {
    log(message?: any, ...optionalParams: any[]): void;
    log(...optionalParams: any[]): void;
}

function puts(...optionalParams: any[]): void {
    console.log(...optionalParams);
}

@DanielRosenwasser
Copy link
Member

This isn't wrong, this is a limitation of our semantics for the spread operator.

@mhegazy
Copy link
Contributor

mhegazy commented Sep 12, 2015

@DanielRosenwasser do you mind filing an issue for that.

@DanielRosenwasser
Copy link
Member

Filed #4759. I'd rather we fixed that instead of the signature for console.log.

@bootstraponline
Copy link
Contributor Author

Agreed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants