diff --git a/src/components/JSONEditor.js b/src/components/JSONEditor.js index e382ea9..9ed8cb1 100644 --- a/src/components/JSONEditor.js +++ b/src/components/JSONEditor.js @@ -43,7 +43,7 @@ export default class JSONEditor extends Component { } } - componentWillReceiveProps (nextProps: {mode: ?string}) { + componentWillReceiveProps (nextProps: {mode?: string}) { if (nextProps.mode !== this.props.mode) { this.setState({ mode: nextProps.mode }) } diff --git a/src/components/JSONNode.js b/src/components/JSONNode.js index 0f0c38e..75dc4b0 100644 --- a/src/components/JSONNode.js +++ b/src/components/JSONNode.js @@ -165,7 +165,7 @@ export default class JSONNode extends Component { } // TODO: simplify the method renderProperty - renderProperty (prop: ?PropertyData, index: ?number, data: JSONData, options: {escapeUnicode: boolean, isPropertyEditable: (Path) => boolean}) { + renderProperty (prop?: PropertyData, index?: number, data: JSONData, options: {escapeUnicode: boolean, isPropertyEditable: (Path) => boolean}) { const isIndex = typeof index === 'number' if (!prop && !isIndex) { @@ -325,7 +325,7 @@ export default class JSONNode extends Component { /** * Get the css style given a search result type */ - static getSearchResultClass (searchResultStatus: ?SearchResultStatus) { + static getSearchResultClass (searchResultStatus?: SearchResultStatus) { if (searchResultStatus === 'active') { return ' jsoneditor-highlight-active' } diff --git a/src/components/JSONNodeForm.js b/src/components/JSONNodeForm.js index af353fa..77552b4 100644 --- a/src/components/JSONNodeForm.js +++ b/src/components/JSONNodeForm.js @@ -22,7 +22,7 @@ export default class JSONNodeForm extends JSONNode { } // render a readonly property - renderProperty (prop: ?PropertyData, index: ?number, data: JSONData, options: {escapeUnicode: boolean, isPropertyEditable: (Path) => boolean}) { + renderProperty (prop?: PropertyData, index?: number, data: JSONData, options: {escapeUnicode: boolean, isPropertyEditable: (Path) => boolean}) { const formOptions = Object.assign({}, options, { isPropertyEditable }) return JSONNode.prototype.renderProperty.call(this, prop, index, data, formOptions) diff --git a/src/jsonData.js b/src/jsonData.js index a966a50..9e49154 100644 --- a/src/jsonData.js +++ b/src/jsonData.js @@ -31,7 +31,7 @@ export function expandAll (path) { * @param {JSONDataType} [type='value'] Optional json data type for the created value * @return {JSONData} */ -export function jsonToData (json, expand = expandAll, path = [], type = 'value') { +export function jsonToData (json, expand = expandAll, path = [], type = 'value') : JSONData { if (Array.isArray(json)) { return { type: 'Array', @@ -57,7 +57,7 @@ export function jsonToData (json, expand = expandAll, path = [], type = 'value') }) } } - else { + else { // value return { type, value: json @@ -166,7 +166,7 @@ export function expand (data: JSONData, callback: Path | (Path) => boolean, expa /** * Expand all Objects and Arrays on a path */ -export function expandPath (data: JSONData, path: ?Path) : JSONData { +export function expandPath (data: JSONData, path?: Path) : JSONData { let updatedData = data if (path) { diff --git a/src/jsonPatchData.js b/src/jsonPatchData.js index 9941d20..308d2fc 100644 --- a/src/jsonPatchData.js +++ b/src/jsonPatchData.js @@ -207,7 +207,7 @@ export function remove (data: JSONData, path: string) { * @param {JSONPatch} patch * @return {Array} */ -function simplifyPatch(patch: JSONPatch) { +export function simplifyPatch(patch: JSONPatch) { const simplifiedPatch = [] const paths = {} diff --git a/src/types.js b/src/types.js index 47f504a..c599c5d 100644 --- a/src/types.js +++ b/src/types.js @@ -39,7 +39,7 @@ export type PropertyData = { id: number, name: string, value: JSONData, - searchResult: ?SearchResultStatus + searchResult?: SearchResultStatus } export type ItemData = { @@ -49,20 +49,20 @@ export type ItemData = { export type ObjectData = { type: 'Object', - expanded: ?boolean, + expanded?: boolean, props: PropertyData[] } export type ArrayData = { type: 'Array', - expanded: ?boolean, + expanded?: boolean, items: ItemData[] } export type ValueData = { type: 'value' | 'string', - value: ?any, - searchResult: ?SearchResultStatus + value?: any, + searchResult?: SearchResultStatus } export type JSONData = ObjectData | ArrayData | ValueData