Skip to content

Commit

Permalink
Upgrade TS, fix error, prompt to use local TS in VS Code
Browse files Browse the repository at this point in the history
Show the prompt that lets VS Code run the local TypeScript version in
your workspace, so it matches the output of `npx tsc`.

---

The error in formGallery/utils.ts is weird. This StackOverflow snippet
checks if something is an instance of an Object or Array. TS2358 aptly
notices that the right-hand side of

   value instanceof Object || value instanceof Array

will never be reached, since an array is also an instanceof Object.

So this could become

   value instanceof Object

…but to preserve the meaning of the code, I've just switched their
order around.

---

Updated TS while I'm at it, since the code still builds without an issue
and it's nice to keep on top of it.
  • Loading branch information
p2edwards committed Jun 26, 2024
1 parent 5f34eee commit 15a4d37
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions jsapp/js/components/formGallery/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Json} from '../common/common.interfaces';
import type {Json} from '../common/common.interfaces';

/**
* Find a key anywhere in an object (supports nesting)
Expand All @@ -22,8 +22,8 @@ export function findByKey(theObject: Json, key: string): Json {
return theObject[key];
}
if (
theObject[prop] instanceof Object ||
theObject[prop] instanceof Array
theObject[prop] instanceof Array ||
theObject[prop] instanceof Object
) {
result = findByKey(theObject[prop], key);
if (result) {
Expand Down
1 change: 1 addition & 0 deletions kpi.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@

// Use locally-installed TypeScript instance (supports plugins in tsconfig)
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
},
}
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"swc-loader": "^0.2.3",
"terser-webpack-plugin": "^5.3.6",
"ts-loader": "^9.4.2",
"typescript": "^5.0.2",
"typescript": "^5.5.2",
"typescript-plugin-css-modules": "^5.0.1",
"webpack": "^5.76.1",
"webpack-bundle-tracker": "^1.5.0",
Expand Down

0 comments on commit 15a4d37

Please sign in to comment.