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

Generic warnings and hints mechanism #1445

Open
Tracked by #1504
cspotcode opened this issue Sep 5, 2021 · 0 comments
Open
Tracked by #1504

Generic warnings and hints mechanism #1445

cspotcode opened this issue Sep 5, 2021 · 0 comments
Milestone

Comments

@cspotcode
Copy link
Collaborator

cspotcode commented Sep 5, 2021

Extracted from #1248

Big idea: there are various places in ts-node where we can emit warnings and hints. We should have a generic mechanism to give them diagnostic codes and let users opt-in or opt-out either fully or per-code.


We discussed this on Discord: https://discord.com/channels/508357248330760243/508357707602853888/843546169752813589

Conclusions:

  • Use node's warnings API: process.emitWarning()
    • there is already precedent for warnings to emit to stderr from here
    • node already has APIs to intercept these warnings and flags to suppress them
  • Match node's behavior and emit each warning only once
  • Add warnings: boolean to API surface
    • false to disable them
    • Future work can expand to suppress or allow warnings by code
  • Add onWarning: callback to API surface
    • if specified, warnings are sent here instead of to process.emitWarning
  • All warnings get a code TSNODE<4-digit number>
    • This is familiar: node's deprecation warnings are DEP1234; TypeScript uses TS1234
    • code allows easy detection in process.on('warning' handlers
  • emit to stderr, not stdout
    • changes to stderr emit typically not considered breaking; stderr has no contract

Questions

  • when tsconfig has "warnings": false, but a warning emits before tsconfig is loaded
    • Do we defer those warnings till after all options are known? For the "target" warning, we can do this
  • ts-node's existing diagnostic logging: does it get diagnostic codes?
  • diagnostic code types
    • warning
    • hint
    • debug / trace
  • TS_NODE_DEBUG or DEBUG env var
    • support full range of include / exclude config supported in tsconfig?
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

1 participant