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

meta: fix TS integration #4741

Merged
merged 2 commits into from
Oct 20, 2023
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
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,22 @@ jobs:
corepack yarn run build:locale-pack
- name: Run type tests
run: corepack yarn run test:type
- name: Drop manual tyoes
# For backward compatiblity reasons, Uppy plugins ship a manual crafted d.ts file.
# We don't want to remove that file to not break users.
# However, we want to validate the types based on the types inferred from source.
run: |
node --input-type=module <<'EOF'
import { existsSync } from 'node:fs';
import { opendir, readFile, writeFile } from 'node:fs/promises';
for await (const dirent of await opendir('./packages/@uppy')) {
if (existsSync(`./packages/@uppy/${dirent.name}/tsconfig.build.json`)) {
const pjsonPath = `./packages/@uppy/${dirent.name}/package.json`
const pjson = JSON.parse(await readFile(pjsonPath));
delete pjson.types
await writeFile(pjsonPath, JSON.stringify(pjson))
}
}
EOF
- name: Attempt building TS packages
run: corepack yarn run build:ts
8 changes: 5 additions & 3 deletions private/js2ts/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ if (packageJSON.type !== 'module') {

const references = Object.keys(packageJSON.dependencies || {})
.concat(Object.keys(packageJSON.peerDependencies || {}))
.concat(Object.keys(packageJSON.devDependencies || {}))
.filter((pkg) => pkg.startsWith('@uppy/'))
.map((pkg) => ({ path: `../${pkg.slice('@uppy/'.length)}` }))
.map((pkg) => ({
path: `../${pkg.slice('@uppy/'.length)}/tsconfig.build.json`,
}))

const depsNotYetConvertedToTS = references.filter(
(ref) =>
!existsSync(new URL(`${ref.path}/tsconfig.json`, packageRoot)),
(ref) => !existsSync(new URL(ref.path, packageRoot)),
)

if (depsNotYetConvertedToTS.length) {
Expand Down