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

fix: ensure string is passed to process.emitWarning #1015

Merged
merged 2 commits into from
Mar 14, 2024

Conversation

mdonnalley
Copy link
Contributor

Errors emitted from ts-node are objects with custom inspections instead of errors or strings, which causes this error when emitting the warning:

TypeError: The "warning" argument must be of type string or an instance of Error. Received src/commands/task/get.tsx(2,9): error TS6133: 'Box' is declared but its value is never read.

    at process.emitWarning (node:internal/process/warning:176:11)
    at Plugin.warn (/Users/mdonnalley/repos/oclif/core/lib/config/plugin.js:372:17)
    at /Users/mdonnalley/repos/oclif/core/lib/config/plugin.js:276:30
    at async Promise.all (index 19)
    at async Plugin._manifest (/Users/mdonnalley/repos/oclif/core/lib/config/plugin.js:257:24)
    at async Plugin.load (/Users/mdonnalley/repos/oclif/core/lib/config/plugin.js:208:25)
    at async PluginLoader.loadRoot (/Users/mdonnalley/repos/oclif/core/lib/config/plugin-loader.js:67:13)
    at async Config.load (/Users/mdonnalley/repos/oclif/core/lib/config/config.js:266:27)
    at async Function.load (/Users/mdonnalley/repos/oclif/core/lib/config/config.js:156:9)
    at async run (/Users/mdonnalley/repos/oclif/core/lib/main.js:59:20)

Calling util.inspect on the object gives a string that we can pass in, so the warning now looks like:

(node:92535) Warning: src/commands/task/get.tsx(2,9): error TS6133: 'Box' is declared but its value is never read.
module: @oclif/core@3.19.6
task: findCommand (task:get)
plugin: multiple-repo-manager
root: /Users/mdonnalley/repos/mdonnalley/multiple-repo-manager
See more details with DEBUG=*
Error: command task:get:done not found
    at Config.runCommand (/Users/mdonnalley/repos/oclif/core/lib/config/config.js:402:19)
    at async run (/Users/mdonnalley/repos/oclif/core/lib/main.js:92:16)
    at async main (file:///Users/mdonnalley/repos/mdonnalley/multiple-repo-manager/bin/dev.js:5:3)
    at async file:///Users/mdonnalley/repos/mdonnalley/multiple-repo-manager/bin/dev.js:8:1

@mdonnalley mdonnalley merged commit 47081db into main Mar 14, 2024
79 checks passed
@mdonnalley mdonnalley deleted the mdonnalley/improve-warning branch March 14, 2024 18:15
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

Successfully merging this pull request may close these issues.

1 participant