diff --git a/src/colors/amber.d.ts b/src/colors/amber.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/amber.d.ts +++ b/src/colors/amber.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/blue.d.ts b/src/colors/blue.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/blue.d.ts +++ b/src/colors/blue.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/blueGrey.d.ts b/src/colors/blueGrey.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/blueGrey.d.ts +++ b/src/colors/blueGrey.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/brown.d.ts b/src/colors/brown.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/brown.d.ts +++ b/src/colors/brown.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/common.d.ts b/src/colors/common.d.ts index 4a580e26bfe494..7f459435e6d35c 100644 --- a/src/colors/common.d.ts +++ b/src/colors/common.d.ts @@ -1,17 +1,25 @@ -import { Color } from '..'; +declare const black: string; +declare const white: string; +declare const transparent: string; +declare const fullBlack: string; +declare const darkBlack: string; +declare const lightBlack: string; +declare const minBlack: string; +declare const faintBlack: string; +declare const fullWhite: string; +declare const darkWhite: string; +declare const lightWhite: string; -interface CommonColors { - black: Color; - white: Color; - transparent: Color; - fullBlack: Color; - darkBlack: Color; - lightBlack: Color; - minBlack: Color; - faintBlack: Color; - fullWhite: Color; - darkWhite: Color; - lightWhite: Color; -} - -export default CommonColors; +export default { + black, + white, + transparent, + fullBlack, + darkBlack, + lightBlack, + minBlack, + faintBlack, + fullWhite, + darkWhite, + lightWhite +}; diff --git a/src/colors/cyan.d.ts b/src/colors/cyan.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/cyan.d.ts +++ b/src/colors/cyan.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/deepOrange.d.ts b/src/colors/deepOrange.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/deepOrange.d.ts +++ b/src/colors/deepOrange.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/deepPurple.d.ts b/src/colors/deepPurple.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/deepPurple.d.ts +++ b/src/colors/deepPurple.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/green.d.ts b/src/colors/green.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/green.d.ts +++ b/src/colors/green.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/grey.d.ts b/src/colors/grey.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/grey.d.ts +++ b/src/colors/grey.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/indigo.d.ts b/src/colors/indigo.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/indigo.d.ts +++ b/src/colors/indigo.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/lightBlue.d.ts b/src/colors/lightBlue.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/lightBlue.d.ts +++ b/src/colors/lightBlue.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/lightGreen.d.ts b/src/colors/lightGreen.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/lightGreen.d.ts +++ b/src/colors/lightGreen.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/lime.d.ts b/src/colors/lime.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/lime.d.ts +++ b/src/colors/lime.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/orange.d.ts b/src/colors/orange.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/orange.d.ts +++ b/src/colors/orange.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/pink.d.ts b/src/colors/pink.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/pink.d.ts +++ b/src/colors/pink.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/purple.d.ts b/src/colors/purple.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/purple.d.ts +++ b/src/colors/purple.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/red.d.ts b/src/colors/red.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/red.d.ts +++ b/src/colors/red.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/teal.d.ts b/src/colors/teal.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/teal.d.ts +++ b/src/colors/teal.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/src/colors/yellow.d.ts b/src/colors/yellow.d.ts index afa2fda881afc8..ac89ca5571d147 100644 --- a/src/colors/yellow.d.ts +++ b/src/colors/yellow.d.ts @@ -1,3 +1,5 @@ import { Color } from '..'; -export default Color; +declare const color: Color; + +export default color; diff --git a/test/typescript/colors.ts b/test/typescript/colors.ts new file mode 100644 index 00000000000000..faddd08b4bcda4 --- /dev/null +++ b/test/typescript/colors.ts @@ -0,0 +1,56 @@ +import { + amber, blue, blueGrey, + brown, cyan, deepOrange, + deepPurple, green, grey, + indigo, lightBlue, lightGreen, + lime, orange, pink, + purple, red, teal, + yellow, common +} from '../../src/colors'; + +[ + // Check if the color is usable as a variable + amber, blue, blueGrey, + brown, cyan, deepOrange, + deepPurple, green, grey, + indigo, lightBlue, lightGreen, + lime, orange, pink, + purple, red, teal, + yellow +].forEach(color => { + // Check if each color is a string + color[50] as string; + color[100] as string; + color[200] as string; + color[300] as string; + color[400] as string; + color[500] as string; + color[600] as string; + color[700] as string; + color[800] as string; + color[900] as string; + color.A100 as string; + color.A200 as string; + color.A400 as string; + color.A700 as string; + + // Check if contrastDefaultColor is a string too + color.contrastDefaultColor as string; +}); + +const { + black, white, transparent, + fullBlack, darkBlack, lightBlack, + minBlack, faintBlack, + fullWhite, darkWhite, lightWhite +} = common; + +[ + black, white, transparent, + fullBlack, darkBlack, lightBlack, + minBlack, faintBlack, + fullWhite, darkWhite, lightWhite +].forEach(color => { + color as string; +}); +