Skip to content

Commit

Permalink
fix(vue-component-meta): resolve @todo should not be required
Browse files Browse the repository at this point in the history
close #2256
  • Loading branch information
johnsoncodehk committed Dec 30, 2022
1 parent 4924fd8 commit ec2c3f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion vue-language-tools/vue-component-meta/src/index.ts
Expand Up @@ -472,7 +472,7 @@ function createSchemaResolvers(
name: tag.name,
text: tag.text?.map(part => part.text).join(''),
})),
required: !Boolean((prop.declarations?.[0] as ts.ParameterDeclaration)?.questionToken ?? false),
required: !(prop.flags & ts.SymbolFlags.Optional),
type: typeChecker.typeToString(subtype),
rawType: rawType ? subtype : undefined,
schema,
Expand Down
12 changes: 6 additions & 6 deletions vue-language-tools/vue-component-meta/tests/index.spec.ts
Expand Up @@ -361,7 +361,7 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ

expect(baz).toBeDefined();
expect(baz?.default).toBeUndefined();
// expect(baz?.required).toBeFalsy(); // @todo should not be required
expect(baz?.required).toBeFalsy();
expect(baz?.type).toEqual('string | undefined');

expect(xfoo).toBeDefined();
Expand All @@ -371,12 +371,12 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ

expect(xbar).toBeDefined();
// expect(xbar?.default).toBe('""'); // @toto should be empty string
// expect(xbar?.required).toBeFalsy(); // @todo should not be required
expect(xbar?.required).toBeFalsy();
expect(xbar?.type).toEqual('string | undefined');

expect(xbaz).toBeDefined();
expect(xbaz?.default).toBeUndefined();
// expect(baz?.required).toBeFalsy(); // @todo should not be required
expect(baz?.required).toBeFalsy();
expect(xbaz?.type).toEqual('string | undefined');
});

Expand Down Expand Up @@ -408,7 +408,7 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ
expect(baz).toBeDefined();
expect(baz?.default).toBeUndefined();
expect(baz?.type).toEqual('string | undefined');
// expect(baz?.required).toBeFalsy(); // @todo should not be required
expect(baz?.required).toBeFalsy();

expect(xfoo).toBeDefined();
expect(xfoo?.default).toBeUndefined();
Expand All @@ -418,12 +418,12 @@ const worker = (checker: ComponentMetaChecker, withTsconfig: boolean) => describ
expect(xbar).toBeDefined();
// expect(xbar?.default).toBe('""'); // @todo should be empty string
expect(xbar?.type).toEqual('string | undefined');
// expect(xbar?.required).toBeFalsy(); // @todo should not be required
expect(xbar?.required).toBeFalsy();

expect(xbaz).toBeDefined();
expect(xbaz?.default).toBeUndefined();
expect(xbaz?.type).toEqual('string | undefined');
// expect(baz?.required).toBeFalsy(); // @todo should not be required
expect(baz?.required).toBeFalsy();

expect(hello).toBeDefined();
expect(hello?.default).toEqual('"Hello"');
Expand Down

0 comments on commit ec2c3f9

Please sign in to comment.