Skip to content

Commit

Permalink
feat: add script to build type definitions for theme folders (#7087)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored Jan 16, 2024
1 parent 4426b22 commit 1e0ddf9
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
packages/**/vendor/*.js
packages/**/dist/*.js
packages/**/test/dom/__snapshots__/*.snap.js
packages/**/theme/**/*.d.ts
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ yarn-error.log
packages/*/test/visual/*/screenshots/*/failed
packages/icons/test/visual/screenshots/failed

# Generated theme folders .ts files
packages/**/theme/**/*.d.ts

# MacOS DS_Store files
.DS_Store

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"private": true,
"author": "Vaadin Ltd",
"scripts": {
"analyze": "polymer analyze packages/**/vaadin-*.js > analysis.json && node scripts/prepareDocs.js && node scripts/buildWebtypes.js && node scripts/generateLumoAutoCompleteCss.js",
"analyze": "polymer analyze packages/**/vaadin-*.js > analysis.json && node scripts/prepareDocs.js && node scripts/buildWebtypes.js && node scripts/generateLumoAutoCompleteCss.js && ./scripts/buildThemeTypings.sh",
"build:ts": "tsc --build tsconfig.build.json",
"debug": "web-test-runner --watch",
"debug:it": "web-test-runner --watch --config web-test-runner-it.config.js",
"dist": "rimraf dist && yarn analyze && rollup -c rollup.config.js && cp analysis.json dist",
Expand Down
16 changes: 16 additions & 0 deletions scripts/buildThemeTypings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# Rename .js files to .ts
for file in packages/**/theme/**/*.js
do
mv "$file" "${file%.js}.ts"
done

# Build type definitions
npm run build:ts

# Restore original .js files
git checkout packages/**/theme/**/*.js

# Remove .ts files but keep .d.ts
find . -path "./packages/*/theme/*.ts" ! -name "*.d.ts" -type f -delete
12 changes: 12 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": ["esnext", "es2018", "dom"],
"declaration": true,
"strict": true,
"skipDefaultLibCheck": true
},
"include": ["packages/**/theme"]
}

0 comments on commit 1e0ddf9

Please sign in to comment.