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

improvement: upgrade typescript and target #10676

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion components/StyledDropzone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const StyledDropzone = ({

onDrop?.(acceptedFiles, fileRejections);
if (collectFilesOnly) {
onSuccess?.(acceptedFiles, fileRejections);
onSuccess?.(acceptedFiles as File[] & UploadedFile[] & UploadedFile, fileRejections);
} else if (useGraphQL) {
uploadFileWithGraphQL(
acceptedFiles.map(file => ({ file, kind, parseDocument, parsingOptions })),
Expand Down
4 changes: 3 additions & 1 deletion lib/currency-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export type Options = {
currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name';
};

type CurrencyDisplay = 'symbol' | 'narrowSymbol' | 'name' | 'code';

Betree marked this conversation as resolved.
Show resolved Hide resolved
function getCurrencySymbolFallback(currency: Currency): string {
return Number(0)
.toLocaleString('en-US', {
Expand Down Expand Up @@ -85,7 +87,7 @@ export function formatCurrency(
maximumFractionDigits = 0;
}

const formatAmount = (currencyDisplay: string): string => {
const formatAmount = (currencyDisplay: CurrencyDisplay): string => {
Betree marked this conversation as resolved.
Show resolved Hide resolved
return amount.toLocaleString(options.locale, {
style: options.style || 'currency',
currency,
Expand Down
8 changes: 4 additions & 4 deletions 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 @@ -286,7 +286,7 @@
"tailwindcss-animate": "1.0.7",
"ts-unused-exports": "^10.1.0",
"tsx": "^4.11.2",
"typescript": "^5.3.2",
"typescript": "^5.6.2",
"url-loader": "^4.1.1",
"webpack": "^5.91.0"
},
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "ESNext",
Copy link
Member

@Betree Betree Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The justification you provide for this change:

The target has been changed in the tsconfig.json file from "es5" to "ESNext". This allows us to use modern JavaScript features, making the code cleaner and more efficient.

Is pretty unclear. Which features? What's cleaner? What's more efficient? The target option impacts the final build. As per the docs:

Modern browsers support all ES6 features, so ES6 is a good choice. You might choose to set a lower target if your code is deployed to older environments, or a higher target if your code is guaranteed to run in newer environments.

The target setting changes which JS features are downleveled and which are left intact. For example, an arrow function () => this will be turned into an equivalent function expression if target is ES5 or lower.

Changing target also changes the default value of lib. You may “mix and match” target and lib settings as desired, but you could just set target for convenience.

For developer platforms like Node there are baselines for the target, depending on the type of platform and its version. You can find a set of community organized TSConfigs at tsconfig/bases, which has configurations for common platforms and their versions.

The special ESNext value refers to the highest version your version of TypeScript supports. This setting should be used with caution, since it doesn’t mean the same thing between different TypeScript versions and can make upgrades less predictable.

So this change introduces a risk of breaking the website for older browser. If we ever do it, there must be a good justification and it must be properly tested for regressions.

Suggested change
"target": "ESNext",
"target": "es5",

"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"checkJs": false,
Expand Down