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

[TypeScript] Add Console Interface #2521

Closed
zekth opened this issue Jun 14, 2019 · 5 comments
Closed

[TypeScript] Add Console Interface #2521

zekth opened this issue Jun 14, 2019 · 5 comments

Comments

@zekth
Copy link
Contributor

zekth commented Jun 14, 2019

Following denoland/std#314

It would be nice to add the interface for the console, to manipulate it throught TypeScript.

@motss
Copy link
Contributor

motss commented Jun 22, 2019

Do you mean exposing an interface Console like the following?

// Existing interface from TypeScript 
interface Console {
    memory: any;
    assert(condition?: boolean, message?: string, ...data: any[]): void;
    clear(): void;
    count(label?: string): void;
    debug(message?: any, ...optionalParams: any[]): void;
    dir(value?: any, ...optionalParams: any[]): void;
    dirxml(value: any): void;
    error(message?: any, ...optionalParams: any[]): void;
    exception(message?: string, ...optionalParams: any[]): void;
    group(groupTitle?: string, ...optionalParams: any[]): void;
    groupCollapsed(groupTitle?: string, ...optionalParams: any[]): void;
    groupEnd(): void;
    info(message?: any, ...optionalParams: any[]): void;
    log(message?: any, ...optionalParams: any[]): void;
    markTimeline(label?: string): void;
    profile(reportName?: string): void;
    profileEnd(reportName?: string): void;
    table(...tabularData: any[]): void;
    time(label?: string): void;
    timeEnd(label?: string): void;
    timeStamp(label?: string): void;
    timeline(label?: string): void;
    timelineEnd(label?: string): void;
    trace(message?: any, ...optionalParams: any[]): void;
    warn(message?: any, ...optionalParams: any[]): void;
}

declare var Console: {
    prototype: Console;
    new(): Console;
};

It can be modified to add only fields that implemented in deno based on https://github.com/denoland/deno/blob/master/js/console.ts#L495.

@bartlomieju
Copy link
Member

Scope of this issue has changed and we'd actually prefer to expose Console class from Deno - this would allow to create custom console in denoland/deno_std testing module that captured all output.

CC @kitsonk what's your opinion?

@kitsonk
Copy link
Contributor

kitsonk commented Jun 22, 2019

I guess that would be better than someone messing with the global console, as just like messing with built-in global prototypes are a bad idea. Would rather people extend Console and create localised instances of something special.

@bartlomieju
Copy link
Member

I guess that would be better than someone messing with the global console, as just like messing with built-in global prototypes are a bad idea. Would rather people extend Console and create localised instances of something special.

Well in testing case it is window.console that is replaced and restored per case basis, but having ability to create instances of Console is much better than creating object without type check

@kitsonk
Copy link
Contributor

kitsonk commented May 20, 2020

Console is exposed globally in Deno. This can be closed.

@zekth zekth closed this as completed May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants