Skip to content

fix(remix): Remove vendored types #16218

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

Merged
merged 2 commits into from
May 8, 2025
Merged
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
Prev Previous commit
Remove a part of vendored functions
  • Loading branch information
onurtemizkan committed May 8, 2025
commit 7ef5353399a542fab535507ac7ccd69f67ad0efd
3 changes: 2 additions & 1 deletion packages/remix/src/server/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
LoaderFunction,
LoaderFunctionArgs,
} from '@remix-run/node';
import { isRouteErrorResponse } from '@remix-run/router';
import type { RequestEventData, Span } from '@sentry/core';
import {
addExceptionMechanism,
Expand All @@ -19,7 +20,7 @@ import {
import { DEBUG_BUILD } from '../utils/debug-build';
import type { RemixOptions } from '../utils/remixOptions';
import { storeFormDataKeys } from '../utils/utils';
import { extractData, isResponse, isRouteErrorResponse } from '../utils/vendor/response';
import { extractData, isResponse } from '../utils/vendor/response';

type DataFunction = LoaderFunction | ActionFunction;

Expand Down
3 changes: 2 additions & 1 deletion packages/remix/src/server/instrumentServer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable max-lines */
import type { AgnosticRouteObject } from '@remix-run/router';
import { isDeferredData, isRouteErrorResponse } from '@remix-run/router';
import type {
ActionFunction,
ActionFunctionArgs,
Expand Down Expand Up @@ -35,7 +36,7 @@ import {
} from '@sentry/core';
import { DEBUG_BUILD } from '../utils/debug-build';
import { createRoutes, getTransactionName } from '../utils/utils';
import { extractData, isDeferredData, isResponse, isRouteErrorResponse, json } from '../utils/vendor/response';
import { extractData, isResponse, json } from '../utils/vendor/response';
import { captureRemixServerException, errorHandleDataFunction, errorHandleDocumentRequestFunction } from './errors';

type AppData = unknown;
Expand Down
36 changes: 1 addition & 35 deletions packages/remix/src/utils/vendor/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import type {
AgnosticRouteMatch,
AgnosticRouteObject,
ErrorResponse,
UNSAFE_DeferredData as DeferredData,
} from '@remix-run/router';
import type { AgnosticRouteMatch, AgnosticRouteObject } from '@remix-run/router';
import { matchRoutes } from '@remix-run/router';
/**
* Based on Remix Implementation
Expand Down Expand Up @@ -129,32 +124,3 @@ export function getRequestMatch(

return match;
}

/**
* https://github.com/remix-run/remix/blob/3e589152bc717d04e2054c31bea5a1056080d4b9/packages/remix-server-runtime/responses.ts#L75-L85
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function isDeferredData(value: any): value is DeferredData {
const deferred: DeferredData = value;
return (
deferred &&
typeof deferred === 'object' &&
typeof deferred.data === 'object' &&
typeof deferred.subscribe === 'function' &&
typeof deferred.cancel === 'function' &&
typeof deferred.resolveData === 'function'
);
}

/**
* https://github.com/remix-run/react-router/blob/f9b3dbd9cbf513366c456b33d95227f42f36da63/packages/router/utils.ts#L1574
*
* Check if the given error is an ErrorResponse generated from a 4xx/5xx
* Response thrown from an action/loader
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function isRouteErrorResponse(value: any): value is ErrorResponse {
const error: ErrorResponse = value;

return error != null && typeof error.status === 'number' && typeof error.statusText === 'string' && 'data' in error;
}
Loading