Comments (3)
hello, same problem here 😑;
UPDATED: solved when adding the await
.
from oclif.github.io.
There is more; the example code does not compile at all. Even ignoring the implicit 'any'
errors that come up in the default configuration generated by oclif, there is this:
src/base/command.ts:20:32 - error TS2559: Type 'Function' has no properties in common with type 'Input<any>'.
20 const {flags} = this.parse(this.constructor)
This works well in plain JS (just like MyCommand.flags
vs this.flags
), but typescript basically does not seem to allow calling this.parse from a base class and having it do the right thing in derived classes...
from oclif.github.io.
I'm wondering the same thing with a project I just started. Wondering if this is resolved? It would seem the docs are outdated relative to the actual project.
Errors:
src/configured-command.ts:13:12 - error TS2339: Property 'flags' does not exist on type 'Promise<ParserOutput<unknown, { [name: string]: any; }>>'.
13 const {flags} = this.parse(this.constructor)
~~~~~
src/configured-command.ts:13:32 - error TS2559: Type 'Function' has no properties in common with type 'Input<unknown>'.
13 const {flags} = this.parse(this.constructor)
~~~~~~~~~~~~~~~~
src/commands/config/create.ts:24:44 - error TS2304: Cannot find name 'Deploy'.
24 const {args, flags} = await this.parse(Deploy)
~~~~~~
src/commands/deploy/index.ts:4:22 - error TS2417: Class static side 'typeof Deploy' incorrectly extends base class static side 'typeof default'.
Types of property 'flags' are incompatible.
Property 'config' is missing in type '{ all: BooleanFlag<boolean>; num: OptionFlag<number | undefined>; }' but required in type '{ config: BooleanFlag<boolean>; }'.
4 export default class Deploy extends Command {
~~~~~~
src/configured-command.ts:5:5
5 config: Flags.boolean({
~~~~~~~~~~~~~~~~~~~~~~~
6 char: 'c',
~~~~~~~~~~~~~~~~
7 description: '',
~~~~~~~~~~~~~~~~~~~~~~
8 }),
~~~~~~
'config' is declared here.
configured-command.ts
import {Command, Flags} from '@oclif/core'
export default abstract class extends Command {
static flags = {
config: Flags.boolean({
char: 'c',
description: 'Path to config file',
}),
}
async init(): Promise<void> {
// do some initialization
const {flags} = this.parse(this.constructor)
console.log('config', flags)
}
}
deploy/index.ts
import {Flags} from '@oclif/core'
import Command from '../../configured-command'
export default class Deploy extends Command {
static summary = 'Deploy new migrations up to the target database.'
static description = 'This command will deploy (a.k.a. push, execute) one or more migrations against a specific target. The command will not execute migrations that have already been executed against the target.'
static examples = ['$ loco deploy']
static flags = {
all: Flags.boolean({
char: 'a',
description: 'Deploy all undeployed migrations in the target migration source folder (declared in the configuration).',
exclusive: ['num'],
}),
num: Flags.integer({
char: 'n',
description: 'Deploy a number of undeployed migrations in the target migration source folder (declared in the configuration). The migrations will be sorted lexicographically before counting them.',
exclusive: ['all'],
}),
}
static args = [{name: 'target', description: 'The target to deploy against, as indicated by the name (or one of the aliases) in the config data. To hit all configured targets, use "*".', required: true}]
async run(): Promise<void> {
const {args, flags} = await this.parse(Deploy)
console.log('deploy args', args)
console.log('deploy flags', flags)
}
}
from oclif.github.io.
Related Issues (20)
- update docs for errors outside of a command HOT 1
- Hook example for TypeScript does not compile
- Can we create platform executables with oclif?
- Documentation is outdated with oclif's v2 and above
- where can I find the v1 docs? HOT 3
- Documentation Doesn't Mention Rebuilding After Generating a New Command
- How to create single cli using oclif v2 HOT 4
- Building your own plugin documentation bug HOT 1
- Custom Base Command class: 'flags' does not exist on type 'default' HOT 1
- More Details Documentation for Release HOT 3
- Page not found HOT 1
- Easy Fix Bug
- Following esm guide leads to "SyntaxError: Cannot use import statement outside a module" for dev.js HOT 1
- Improve and finalize ESM documentation HOT 2
- OCLIF architecture diagram outdated
- Please improve Release docs with prerequisites HOT 3
- Better getting started tutorial? HOT 1
- The CLI Flags Explained links to 'Page Not Found' HOT 4
- Please document that oclif commands interpret stdin as positional arguments HOT 1
- Broken link on introduction page
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oclif.github.io.