Skip to content

Commit

Permalink
Merge pull request #11756 from nanaya/ts-type-thing
Browse files Browse the repository at this point in the history
Explicit typescript types and rename webpack define const
  • Loading branch information
notbakaneko authored Dec 20, 2024
2 parents 3a3ab74 + 5006038 commit 79a6ee3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
12 changes: 2 additions & 10 deletions resources/js/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,8 @@ interface Window {
}
// #endregion

// #region interfaces for using process.env
interface Process {
env: ProcessEnv;
}

interface ProcessEnv {
[key: string]: string | undefined;
}

declare const process: Process;
// #region defined through webpack DefinePlugin
declare const docsUrl: string;
// #endregion

// our helpers
Expand Down
2 changes: 1 addition & 1 deletion resources/js/legacy-api-key/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default class Form extends React.Component<Props> {
<div>
<StringWithComponent
mappings={{ link: (
<a href={`${process.env.DOCS_URL}#terms-of-use`}>
<a href={`${docsUrl}#terms-of-use`}>
{trans('oauth.new_client.terms_of_use.link')}
</a>
) }}
Expand Down
2 changes: 1 addition & 1 deletion resources/js/oauth/new-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class NewClient extends React.Component {
<div>
<StringWithComponent
mappings={{ link: (
<a href={`${process.env.DOCS_URL}#terms-of-use`}>
<a href={`${docsUrl}#terms-of-use`}>
{trans('oauth.new_client.terms_of_use.link')}
</a>
) }}
Expand Down
7 changes: 7 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
"strictNullChecks": true,
"strictPropertyInitialization": true,
"target": "es2015",
"types": [
"cloudflare-turnstile",
"jquery.fileupload",
"jquery.scrollto",
"jqueryui",
"timeago"
],
"useDefineForClassFields": true
},
"include": [
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const plugins = [
ReactDOM: 'react-dom',
}),
new webpack.DefinePlugin({
'process.env.DOCS_URL': JSON.stringify(process.env.DOCS_URL || 'https://docs.ppy.sh'),
docsUrl: JSON.stringify(process.env.DOCS_URL ?? 'https://docs.ppy.sh'),
}),
new webpack.IgnorePlugin({
// don't add moment locales to bundle.
Expand Down

0 comments on commit 79a6ee3

Please sign in to comment.