question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FeatureRequest] rename `.default` method

See original GitHub issue

Brief

strictOptions can not be trigger under require("yargs").default

Background

official document

// x.ts
import yargs from 'yargs'
// tsc output x.js is something like
const yargs = require("yargs").default

Expected

require("yargs").default(["bar", "-a", "10"]).strictOptions().argv
// Error
Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]

Unknown argument: a

Actual

require("yargs").default(["bar", "-a", "10"]).strictOptions().argv
// Error is not trigger
{
  '10': undefined,
  _: [],
  bar: undefined,
  '-a': undefined,
  a: undefined,
  '$0': ''
}

Workaround

// y.ts
import * as yargs from 'yargs'
// tsc output y.js is something like
var yargs = require("yargs");

Reproduce Gist

gist

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
loynoircommented, May 21, 2021

Still think might be better to rename .default. So, when missing "esModuleInterop": true, error is raised instead of silent failure.

@karizma @bcoe Anyway, thanks for your reply. Wish you have a nice day. 😃

0reactions
bcoecommented, May 21, 2021

@loynoir, as @karizma says you should be able to use .defaults, rather than default, and work around your compilation issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Renaming component's default state – Adobe XD Feedback
Let us be able to rename the component's default state, so it can make more sense during the component building process.
Read more >
Renaming Feature Requests to Feedback - Airfocus
If you rename feature requests to feedback and treat them alike, magic happens. It helps you focising on problems and outcomes.
Read more >
Renaming the default branch from master - GitHub
Renaming existing branches​​ You can now rename any branch, including the default branch, from the web. Renaming a branch will: Re-target any open...
Read more >
Solved: Is there a way to delete "Default State"? (or repl...
Solved: I like my states to be named exactly what they are. So I've consistently ignored default state and made a "New State"...
Read more >
Easily rename your Git default branch from master to main
Go to the master branch · Rename master to main locally · Get the latest commits from the server · Remove the link...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found