Skip to content

Commit bdc7e80

Browse files
authored
Merge pull request #671 from LekoArts/ts-custom-properties
fix(@theme-ui/custom-properties): TS conversion
2 parents d92d072 + e570dc0 commit bdc7e80

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ node_modules
55
dist
66
coverage
77
.DS_Store
8-
.rts2_cache*
8+
.rts2_cache*
9+
.idea

packages/custom-properties/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22
"name": "@theme-ui/custom-properties",
33
"description": "Generate CSS custom properties for use with Theme UI",
44
"version": "0.3.0",
5+
"source": "src/index.ts",
56
"main": "dist/index.js",
67
"module": "dist/index.esm.js",
8+
"types": "dist/index.d.ts",
79
"author": "Alex Page <[email protected]>",
810
"license": "MIT",
911
"scripts": {
10-
"prepare": "microbundle --no-compress",
11-
"watch": "microbundle watch --no-compress"
12+
"prepare": "microbundle --no-compress --tsconfig tsconfig.json",
13+
"watch": "microbundle watch --no-compress --tsconfig tsconfig.json"
1214
},
1315
"publishConfig": {
1416
"access": "public"
1517
},
1618
"dependencies": {
1719
"pluralize": "^8.0.0"
20+
},
21+
"devDependencies": {
22+
"@theme-ui/core": "^0.3.1",
23+
"@types/pluralize": "^0.0.29"
1824
}
1925
}

packages/custom-properties/src/index.js renamed to packages/custom-properties/src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import pluralize from 'pluralize'
2+
import { Theme } from '@theme-ui/core'
23

3-
export default (theme, prefix) => {
4-
const customProperties = {}
4+
interface CustomProperties {
5+
[key: string]: string | number
6+
}
7+
8+
export default (theme: Theme, prefix?: string) => {
9+
const customProperties: CustomProperties = {}
510

6-
const generateProperties = (object, previousKey) => {
11+
const generateProperties = (object: object, previousKey?: string) => {
712
Object.entries(object).forEach(([key, value]) => {
813
let formattedKey = pluralize(key, 1)
914

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"resolveJsonModule": true,
4+
"esModuleInterop": true,
5+
"moduleResolution": "node",
6+
"strict": true
7+
}
8+
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3506,6 +3506,11 @@
35063506
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
35073507
integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==
35083508

3509+
"@types/pluralize@^0.0.29":
3510+
version "0.0.29"
3511+
resolved "https://registry.yarnpkg.com/@types/pluralize/-/pluralize-0.0.29.tgz#6ffa33ed1fc8813c469b859681d09707eb40d03c"
3512+
integrity sha512-BYOID+l2Aco2nBik+iYS4SZX0Lf20KPILP5RGmM1IgzdwNdTs0eebiFriOPcej1sX9mLnSoiNte5zcFxssgpGA==
3513+
35093514
"@types/prop-types@*":
35103515
version "15.7.3"
35113516
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"

0 commit comments

Comments
 (0)