Skip to content

Commit

Permalink
Merge pull request #329 from guardian/use-esnext
Browse files Browse the repository at this point in the history
upgrade to latest Typescript and use `esnext` to utilise latest language features
  • Loading branch information
twrichards authored Dec 10, 2024
2 parents bfff1b9 + 0cf64d1 commit 0a22003
Show file tree
Hide file tree
Showing 5 changed files with 1,024 additions and 90 deletions.
20 changes: 5 additions & 15 deletions client/src/fronts/frontsIntegration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,11 @@ export const FrontsIntegration = ({
}: {
frontsPinboardElements: HTMLElement[];
}) => {
const pathToElementsMap: { [path: string]: HTMLElement[] } = useMemo(
const pathToElementsMap: Partial<{ [path: string]: HTMLElement[] }> = useMemo(
() =>
frontsPinboardElements.reduce(
// TODO could be replaced with groupBy if we upgrade to Node21 plus set lib to esnext in tsconfig
(acc, htmlElement) =>
htmlElement.dataset.urlPath
? {
...acc,
[htmlElement.dataset.urlPath]: [
...(acc[htmlElement.dataset.urlPath] || []),
htmlElement,
],
}
: acc,
{} as Record<string, HTMLElement[]>
Object.groupBy(
frontsPinboardElements,
(htmlElement) => htmlElement.dataset.urlPath ?? "undefined"
),
[frontsPinboardElements]
);
Expand Down Expand Up @@ -108,7 +98,7 @@ export const FrontsIntegration = ({
<>
{Object.entries(pathToElementsMap).map(
([path, htmlElementsToMountInto]) =>
htmlElementsToMountInto.map((htmlElementToMountInto) =>
htmlElementsToMountInto!.map((htmlElementToMountInto) =>
ReactDOM.createPortal(
<FrontsPinboardArticleButton
maybePinboardData={pathToPinboardDataMap[path]}
Expand Down
1 change: 0 additions & 1 deletion email-lambda/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"lib": ["es2020.promise"],
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@guardian/node-riffraff-artifact": "0.3.2",
"@types/aws-lambda": "^8.10.114",
"@types/jest": "^26.0.22",
"@types/node": "^18.15.11",
"@types/node": "^22.10.1",
"@types/node-fetch": "^2.6.3",
"@types/prompts": "^2.0.14",
"@typescript-eslint/eslint-plugin": "^4.11.1",
Expand All @@ -56,7 +56,7 @@
"prompts": "^2.4.2",
"ts-jest": "^26.5.4",
"tsafe": "^1.0.1",
"typescript": "^5.0.2",
"typescript": "^5.7.2",
"wsrun": "^5.2.4",
"yarn-run-all": "^3.1.1"
},
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// "incremental": true, /* Enable incremental compilation */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"lib": ["es2020"], /* Specify library files to be included in the compilation. */
"lib": ["esnext"], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
Expand Down
Loading

0 comments on commit 0a22003

Please sign in to comment.