Skip to content

Commit

Permalink
Merge branch 'ts-provider-views' of https://github.com/transloadit/uppy
Browse files Browse the repository at this point in the history
… into ts-provider-views

* 'ts-provider-views' of https://github.com/transloadit/uppy:
  Return promises
  Apply suggestions from code review
  rename generic
  Apply suggestions from code review
  Fix build
  fixup! Remove unrelated change
  Remove unrelated change
  @uppy/provider-views: migrate to TS
  uppy: remove legacy bundle
  meta: remove `@uppy/angular` build while we are typing everything
  meta: include types in npm archive
  @uppy/angular: fix build
  Remove generate types from locale-pack
  meta: enable CI on `4.x` branch
  [v4.x] remove manual types (#4803)
  meta: prepare release workflow for beta versions
  • Loading branch information
Murderlon committed Jan 18, 2024
2 parents f09b73e + 5f09293 commit e93ef8e
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 479 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,38 +95,5 @@ jobs:
env:
# https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
CYPRESS_INSTALL_BINARY: 0
# Need to do a bunch of work to generate the locale typings 🙃
- name: Prepare type declarations
run: |
corepack yarn run build:lib
corepack yarn run build:companion
corepack yarn run build:locale-pack
find packages/@uppy -name 'tsconfig.json' -delete
- 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: |
git checkout -- packages/@uppy
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))
}
}
const pjsonPath = `./packages/uppy/package.json`
const pjson = JSON.parse(await readFile(pjsonPath));
delete pjson.types
await writeFile(pjsonPath, JSON.stringify(pjson))
EOF
echo > packages/uppy/types/index.test-d.ts
rm -r packages/@uppy/*/types
- name: Attempt building TS packages
run: corepack yarn run build:ts
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@
"test:locale-packs": "yarn locale-packs:unused && yarn locale-packs:warnings",
"test:locale-packs:unused": "yarn workspace @uppy-dev/locale-pack test unused",
"test:locale-packs:warnings": "yarn workspace @uppy-dev/locale-pack test warnings",
"test:type": "yarn workspaces foreach -piv --include '@uppy/*' --exclude '@uppy/{angular,react-native,locales,companion,provider-views,robodog,svelte}' exec tsd",
"test:unit": "yarn run build:lib && yarn test:watch --run",
"test:watch": "vitest --environment jsdom --dir packages/@uppy",
"test": "npm-run-all lint test:locale-packs:unused test:unit test:type test:companion",
Expand Down
13 changes: 1 addition & 12 deletions packages/@uppy/core/src/Uppy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import Translator from '@uppy/utils/lib/Translator'
import ee from 'namespace-emitter'
import { nanoid } from 'nanoid/non-secure'
import throttle from 'lodash/throttle.js'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore store-default types not always available on that branch
import DefaultStore from '@uppy/store-default'
import getFileType from '@uppy/utils/lib/getFileType'
import getFileNameAndExtension from '@uppy/utils/lib/getFileNameAndExtension'
Expand Down Expand Up @@ -134,8 +132,7 @@ export interface UppyOptions<M extends Meta, B extends Body> {
[key: string]: UppyFile<M, B>
}) => { [key: string]: UppyFile<M, B> } | boolean
locale?: Locale
// TODO: add <State<M, B>> when landing on `4.x`
store?: DefaultStore
store?: DefaultStore<State<M, B>>
infoTimeout?: number
}

Expand Down Expand Up @@ -393,11 +390,7 @@ export class Uppy<M extends Meta, B extends Body> {
this.#restricter = new Restricter<M, B>(() => this.opts, this.i18n)

this.#storeUnsubscribe = this.store.subscribe(
// eslint-disable-next-line
// @ts-ignore Store is incorrectly typed
(prevState, nextState, patch) => {
// eslint-disable-next-line
// @ts-ignore Store is incorrectly typed
this.emit('state-update', prevState, nextState, patch)
this.updateAll(nextState)
},
Expand Down Expand Up @@ -470,17 +463,13 @@ export class Uppy<M extends Meta, B extends Body> {
* Updates state with a patch
*/
setState(patch?: Partial<State<M, B>>): void {
// eslint-disable-next-line
// @ts-ignore Store is incorrectly typed
this.store.setState(patch)
}

/**
* Returns current state.
*/
getState(): State<M, B> {
// eslint-disable-next-line
// @ts-ignore Store is incorrectly typed
return this.store.getState()
}

Expand Down

0 comments on commit e93ef8e

Please sign in to comment.