Skip to content

Commit

Permalink
chore(flow): Update types on directional shorthands
Browse files Browse the repository at this point in the history
Update types on directional shorthands to properly show values array elements are nullable.
  • Loading branch information
bhough committed Dec 17, 2016
1 parent 72c3dd3 commit e1feb49
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 567 deletions.
598 changes: 39 additions & 559 deletions docs/docs/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/helpers/directionalProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function generateProperty(property: string, position: string) {
return splitPropertyName.join('-')
}

function generateStyles(property: string, valuesWithDefaults: Array<string|null>) {
function generateStyles(property: string, valuesWithDefaults: Array<?string>) {
const styles = {}
for (let i = 0; i < valuesWithDefaults.length; i += 1) {
if (valuesWithDefaults[i]) {
Expand Down Expand Up @@ -41,7 +41,7 @@ function generateStyles(property: string, valuesWithDefaults: Array<string|null>
* }
*/

function directionalProperty(property: string, ...values: Array<string|null>) {
function directionalProperty(property: string, ...values: Array<?string>) {
// $FlowIgnoreNextLine doesn't understand destructuring with chained defaults.
const [firstValue, secondValue = firstValue, thirdValue = firstValue, fourthValue = secondValue] = values
const valuesWithDefaults = [firstValue, secondValue, thirdValue, fourthValue]
Expand Down
2 changes: 1 addition & 1 deletion src/shorthands/borderColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import directionalProperty from '../helpers/directionalProperty'
* }
*/

function borderColor(...values: Array<string|null>) {
function borderColor(...values: Array<?string>) {
return directionalProperty('border-color', ...values)
}

Expand Down
2 changes: 1 addition & 1 deletion src/shorthands/borderStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import directionalProperty from '../helpers/directionalProperty'
* }
*/

function borderStyle(...values: Array<string|null>) {
function borderStyle(...values: Array<?string>) {
return directionalProperty('border-style', ...values)
}

Expand Down
2 changes: 1 addition & 1 deletion src/shorthands/borderWidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import directionalProperty from '../helpers/directionalProperty'
* }
*/

function borderWidth(...values: Array<string|null>) {
function borderWidth(...values: Array<?string>) {
return directionalProperty('border-width', ...values)
}

Expand Down
2 changes: 1 addition & 1 deletion src/shorthands/margin.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import directionalProperty from '../helpers/directionalProperty'
* }
*/

function margin(...values: Array<string|null>) {
function margin(...values: Array<?string>) {
return directionalProperty('margin', ...values)
}

Expand Down
2 changes: 1 addition & 1 deletion src/shorthands/padding.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import directionalProperty from '../helpers/directionalProperty'
* }
*/

function padding(...values: Array<string|null>) {
function padding(...values: Array<?string>) {
return directionalProperty('padding', ...values)
}

Expand Down
2 changes: 1 addition & 1 deletion src/shorthands/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const positionMap = ['absolute', 'fixed', 'relative', 'static', 'sticky']
* }
*/

function position(positionKeyword: string|null, ...values: Array<string|null>) {
function position(positionKeyword: string|null, ...values: Array<?string>) {
if (positionMap.includes(positionKeyword)) {
return {
position: positionKeyword,
Expand Down

0 comments on commit e1feb49

Please sign in to comment.