Skip to content

Commit

Permalink
Updating
Browse files Browse the repository at this point in the history
  • Loading branch information
uglycoyote committed Jan 15, 2018
1 parent 7069247 commit 5c794ba
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ In this repo, the setup is similar, except

### Taking Advantage of Typescript

I have included a file
I have included a file ```BuildbotJsonInterfaces.ts``` containing a bunch of interface descriptions for the data which is available using the JSON API. These interfaces are automatically generated by requesting URL's such as http://nine.buildbot.net/api/v2/changes?limit=10 and then using [json2ts](https://github.com/GregorBiswanger/json2ts) to convert the json into typescript interfaces.

![](https://github.com/uglycoyote/buildbot-react-plugin-boilerplate/blob/master/documentation/TypescriptBuildbotCompletion.gif?raw=true)
By importing the interfaces using

```import {Change, Build} from 'BuildbotJsonInterface'```

you will get auto-completion in Visual Studio Code or Sublime Text (or other editor's using the Typescript Language services.)



![](https://github.com/uglycoyote/buildbot-react-plugin-boilerplate/blob/master/documentation/Completion.png?raw=true)



![](https://github.com/uglycoyote/buildbot-react-plugin-boilerplate/blob/master/documentation/Error.png?raw=true)
Binary file removed documentation/TypescriptBuildbotCompletion.gif
Binary file not shown.
4 changes: 2 additions & 2 deletions src/SampleReactComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
// import * from '../typings/buildbot'
import {Change, Build} from 'BuildbotJsonInterfaces'

// // stuff like this should go into some common .d.ts that describes the common data structures
// // in buildbot so that Typescript can take advantage of this info for auto-completion and
Expand Down Expand Up @@ -32,8 +33,7 @@ export class ChangeRow extends React.Component<ChangeRowProps, any> {
comments = comments.substring(0, 512) + "...";
}


let files = this.props.change.files.length + " files"
let files = this.props.change.files.length + " files";

return <tr key={this.props.change.revision}>
<td key="revision">
Expand Down

0 comments on commit 5c794ba

Please sign in to comment.