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

[Feature Request] Better typescript support #2

Open
Olian04 opened this issue Aug 5, 2018 · 4 comments
Open

[Feature Request] Better typescript support #2

Olian04 opened this issue Aug 5, 2018 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Olian04
Copy link
Owner

Olian04 commented Aug 5, 2018

  1. This is all you should have to do no matter if you decorate the console or a random object.
require('better-logging')(console);
  1. If you decorate a random object the types for the console is still being updated (since its a global type extension)
const better = {};
if (!require('better-logging').default(better)) throw 'This will never happen';
better.line(); // ts-valid, runtime-valid
console.line(); // ts-valid, runtime-error
@Olian04 Olian04 added the enhancement New feature or request label Aug 5, 2018
@Olian04
Copy link
Owner Author

Olian04 commented Oct 10, 2018

Something is up with the typings. They work just fine with vscode and js. But fail when processed by tsc when used in an actual ts file.

@Olian04
Copy link
Owner Author

Olian04 commented Oct 10, 2018

Fixed most issues with ts in 2.x. Though you still have to use the throw workaround for the time being.

@Olian04
Copy link
Owner Author

Olian04 commented Oct 10, 2018

Perhaps we should just drop support for custom objects? At least untill typescript adds support for type mutations.

@Olian04
Copy link
Owner Author

Olian04 commented Oct 10, 2018

https://stackoverflow.com/q/52743661/6224823

Apparently it might work better if we use const better = {} instead of let better = {}... for some reason ts thinks const makes the object immutable... that seems like a bug/oversight

@Olian04 Olian04 added the help wanted Extra attention is needed label Nov 28, 2018
@Olian04 Olian04 changed the title Better typescript support [Feature Request] Better typescript support Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant