Open jpgorman opened 3 years ago
Try:
const options = {
flags: {
rainbow: {
type: 'boolean',
alias: 'r'
}
}
} as const;
meow(`...`, options)
or putting the object literal inline.
Thanks for the very fast response.
I've taken a look and I can confirm that:
The first option of using const
results in a syntax error.
The second option of passing the options inline does remove that type error, however I'm not getting a typed interface on the return meow object.
The problem with the second option though is that you can't then use the options outside of that function call.
Would it be an option to export the options type and then use that when defining my options object e.g,
import { Options } from 'meow'
const options: Options = {
flags: {
rainbow: {
type: 'boolean',
alias: 'r'
}
}
The first option of using const results in a syntax error.
Make sure you're on the latest TS version.
I'm currently using 4.1.3
What version of typescript are you using to test types? I wasn't sure after looking at the package.json
Also I check that it isn't a case of my IDE not respecting const assertions
So I tried again using the const assertions approach and I was getting the same type errors.
TS 4.1.2
Thanks for your help. I'm not sure why i'm getting such a different result. For now I've stubbed out the types for the library to get it working in my project.
Getting something similar using npx create-ink-app
The root cause is create-ink-app
always using the latest version of meow
and @sindresorhus/tsconfig
. create-ink-app
is using a simple install script to install them without a specific version. By default, you will get the latest version.
Since meow@10.0.0, we moved our package to ESM.
I will help create-ink-app move their package to ESM. It will take some time because there are some blocking dependencies that need to be moved to ESM as well.
Before that, you could downgrade your meow
to 9.0.0 or lower manually (just modify your generated code and reinstall dependencies).
Update:\ I submitted a quick fix for CommonJS modules.
os: windows10 node: v10.15.1 terminal: WSL