Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add script to build type definitions for theme folders #7087

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
}