Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
findLast
Browse files Browse the repository at this point in the history
istarkov committed Jun 5, 2024

Verified

This commit was signed with the committer’s verified signature.
renovate-bot Mend Renovate
1 parent fd20af7 commit da9bf5b
Showing 15 changed files with 30 additions and 24 deletions.
7 changes: 4 additions & 3 deletions fixtures/webstudio-cloudflare-template/app/root.tsx
Original file line number Diff line number Diff line change
@@ -9,10 +9,11 @@ const Root = () => {
// Get language from matches
const matches = useMatches();

const lastMatchWithLanguage = [...matches]
.reverse()
const lastMatchWithLanguage = matches.findLast((match) => {
// @ts-ignore
.find((match) => match?.data?.pageMeta?.language != null);
const language = match?.data?.pageMeta?.language;
return language != null;
});

// @ts-ignore
const lang = lastMatchWithLanguage?.data?.pageMeta?.language ?? "en";
2 changes: 1 addition & 1 deletion fixtures/webstudio-cloudflare-template/tsconfig.json
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
"**/.client/**/*.tsx"
],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"lib": ["DOM", "DOM.Iterable", "ES2023"],
"types": [
"@remix-run/cloudflare",
"vite/client",
2 changes: 1 addition & 1 deletion fixtures/webstudio-custom-template/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"lib": ["DOM", "DOM.Iterable", "ES2023"],
"types": ["@remix-run/node", "vite/client"],
"isolatedModules": true,
"esModuleInterop": true,
7 changes: 4 additions & 3 deletions fixtures/webstudio-remix-netlify-edge-functions/app/root.tsx
Original file line number Diff line number Diff line change
@@ -9,10 +9,11 @@ const Root = () => {
// Get language from matches
const matches = useMatches();

const lastMatchWithLanguage = [...matches]
.reverse()
const lastMatchWithLanguage = matches.findLast((match) => {
// @ts-ignore
.find((match) => match?.data?.pageMeta?.language != null);
const language = match?.data?.pageMeta?.language;
return language != null;
});

// @ts-ignore
const lang = lastMatchWithLanguage?.data?.pageMeta?.language ?? "en";
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"lib": ["DOM", "DOM.Iterable", "ES2023"],
"types": ["@remix-run/node", "vite/client"],
"isolatedModules": true,
"esModuleInterop": true,
7 changes: 4 additions & 3 deletions fixtures/webstudio-remix-netlify-functions/app/root.tsx
Original file line number Diff line number Diff line change
@@ -9,10 +9,11 @@ const Root = () => {
// Get language from matches
const matches = useMatches();

const lastMatchWithLanguage = [...matches]
.reverse()
const lastMatchWithLanguage = matches.findLast((match) => {
// @ts-ignore
.find((match) => match?.data?.pageMeta?.language != null);
const language = match?.data?.pageMeta?.language;
return language != null;
});

// @ts-ignore
const lang = lastMatchWithLanguage?.data?.pageMeta?.language ?? "en";
2 changes: 1 addition & 1 deletion fixtures/webstudio-remix-netlify-functions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"lib": ["DOM", "DOM.Iterable", "ES2023"],
"types": ["@remix-run/node", "vite/client"],
"isolatedModules": true,
"esModuleInterop": true,
7 changes: 4 additions & 3 deletions fixtures/webstudio-remix-vercel/app/root.tsx
Original file line number Diff line number Diff line change
@@ -9,10 +9,11 @@ const Root = () => {
// Get language from matches
const matches = useMatches();

const lastMatchWithLanguage = [...matches]
.reverse()
const lastMatchWithLanguage = matches.findLast((match) => {
// @ts-ignore
.find((match) => match?.data?.pageMeta?.language != null);
const language = match?.data?.pageMeta?.language;
return language != null;
});

// @ts-ignore
const lang = lastMatchWithLanguage?.data?.pageMeta?.language ?? "en";
2 changes: 1 addition & 1 deletion fixtures/webstudio-remix-vercel/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"lib": ["DOM", "DOM.Iterable", "ES2023"],
"types": ["@remix-run/node", "vite/client"],
"isolatedModules": true,
"esModuleInterop": true,
2 changes: 1 addition & 1 deletion packages/cli/templates/cloudflare/tsconfig.json
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
"**/.client/**/*.tsx"
],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"lib": ["DOM", "DOM.Iterable", "ES2023"],
"types": [
"@remix-run/cloudflare",
"vite/client",
7 changes: 4 additions & 3 deletions packages/cli/templates/defaults/app/root.tsx
Original file line number Diff line number Diff line change
@@ -9,10 +9,11 @@ const Root = () => {
// Get language from matches
const matches = useMatches();

const lastMatchWithLanguage = [...matches]
.reverse()
const lastMatchWithLanguage = matches.findLast((match) => {
// @ts-ignore
.find((match) => match?.data?.pageMeta?.language != null);
const language = match?.data?.pageMeta?.language;
return language != null;
});

// @ts-ignore
const lang = lastMatchWithLanguage?.data?.pageMeta?.language ?? "en";
2 changes: 1 addition & 1 deletion packages/cli/templates/defaults/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"types": ["@remix-run/node", "vite/client"],
"isolatedModules": true,
"esModuleInterop": true,
2 changes: 1 addition & 1 deletion packages/cli/templates/internal/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"lib": ["DOM", "DOM.Iterable", "ES2023"],
"types": ["@remix-run/node", "vite/client"],
"isolatedModules": true,
"esModuleInterop": true,
2 changes: 1 addition & 1 deletion packages/cli/templates/saas-helpers/tsconfig.json
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
"**/.client/**/*.tsx"
],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"lib": ["DOM", "DOM.Iterable", "ES2023"],
"types": [
"@remix-run/cloudflare",
"vite/client",
1 change: 1 addition & 0 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
"extends": "@webstudio-is/tsconfig/base.json",
"include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"types": ["vite/client"],
"module": "esnext",
"allowJs": true,

0 comments on commit da9bf5b

Please sign in to comment.