Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
feat: Added support for ref attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
KnisterPeter committed Feb 1, 2016
1 parent f7076e6 commit d6f5b46
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ export class Generator {
public props(name: string, props: IPropTypes, fn?: () => void): void {
this.interface(`${name}Props`, () => {
this.prop('key', 'any', true);
this.prop('ref', 'any', true);
Object.keys(props).forEach((propName: any) => {
const prop: IProp = props[propName];
this.prop(propName, prop.type, prop.optional, prop.documentation);
Expand Down
1 change: 1 addition & 0 deletions tests/es6-class.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ declare module 'component' {

export interface ComponentProps {
key?: any;
ref?: any;
/**
* This is a jsdoc comment for optionalAny.
*/
Expand Down
1 change: 1 addition & 0 deletions tests/es7-class.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ declare module 'component' {

export interface ComponentProps {
key?: any;
ref?: any;
/**
* This is a jsdoc comment for optionalAny.
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/generator-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('The Generator', () => {
});
it('should write a property interface', () => {
generator.props('Name', {prop: {type: 'type', optional: true}});
assert.equal(generator.toString(), 'export interface NameProps {\n\tkey?: any;\n\tprop?: type;\n}\n');
assert.equal(generator.toString(), 'export interface NameProps {\n\tkey?: any;\n\tref?: any;\n\tprop?: type;\n}\n');
});
it('should write a class with props declaration', () => {
generator.class('Name', true);
Expand Down

0 comments on commit d6f5b46

Please sign in to comment.