Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Add progressive TypeScript compilation (#503)
Browse files Browse the repository at this point in the history
* Add progressive TypeScript compilation

* Add missing include

* Add CI step for typescript

* Run prettier on tsconfig.json
  • Loading branch information
sarayourfriend authored Dec 9, 2021
1 parent 27e20e5 commit c5388da
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/pre-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ jobs:
- name: lint & syntax check
run: npm run lint

# run type checker
- name: typescript
run: npm run types
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ if [[ "$CHANGED" == *"$TRANSFILE"* ]] && [[ "$CHANGED" != *"$POTFILE"* ]]; then
fi

# Lint staged files
npx lint-staged
npx lint-staged && npm run types
10 changes: 0 additions & 10 deletions jsconfig.json

This file was deleted.

17 changes: 8 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"run-server": "cross-env ENABLE_AUDIO=true nuxt build && npm run start",
"e2e:ci": "start-server-and-test run-server http://localhost:8443 test:e2e",
"generate-e2e-tests": "playwright codegen localhost:8443/",
"types": "tsc --noEmit",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"lintfix": "eslint --fix --ext .js,.vue --ignore-path .gitignore .",
"format": "prettier --write .",
Expand Down Expand Up @@ -103,6 +104,7 @@
"start-server-and-test": "^1.14.0",
"tailwindcss": "^2.2.7",
"tailwindcss-rtl": "^0.7.3",
"typescript": "^4.5.2",
"vue-i18n-extract": "^2.0.0",
"vue-jest": "^3.0.7"
},
Expand Down
15 changes: 7 additions & 8 deletions src/composables/use-event-listener-outside.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ export const useEventListenerOutside = ({
const boundEventRef = ref()

watch(
[containerRef, triggerRef, shouldListenRef],
/**
* @param {[HTMLElement, HTMLElement, boolean]} deps
* @param {unknown} _
* @param {(cb: () => void) => void} onInvalidate
*/
/** @type {const} */ ([
containerRef,
triggerRef,
shouldListenRef || ref(false),
]),
([container, trigger, shouldListen], _, onInvalidate) => {
if (boundEventRef.value && !shouldListen) {
const document = getDocument(container)
Expand All @@ -50,9 +49,9 @@ export const useEventListenerOutside = ({
* @param {Event} event
*/
const onEvent = (event) => {
if (!listener) return
if (!listener || !container || !(event.target instanceof Element))
return
const target = event.target
if (!container) return

// When an element is unmounted right after it receives focus, the focus
// event is triggered after that, when the element isn't part of the
Expand Down
40 changes: 40 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"allowSyntheticDefaultImports": true,
"jsx": "preserve",
"target": "esnext",
"module": "esnext",
"lib": ["dom", "esnext"],
"declaration": true,
"declarationMap": true,
"noEmit": true,
"isolatedModules": true,
"skipLibCheck": true,

/* Strict Type-Checking Options */
"strict": true,

/* Additional Checks */
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"importsNotUsedAsValues": "error",

/* Module Resolution Options */
"moduleResolution": "node",
"resolveJsonModule": true,
"typeRoots": ["./node_modules/@types"],
"paths": {
"~/*": ["./src/*"],
"~~/*": ["./*"]
},
"baseUrl": "./"
},
"include": [
"src/composables/types.js",
"src/composables/use-event-listener-outside.js"
]
}

0 comments on commit c5388da

Please sign in to comment.