Repository: vercel/next.js
File: packages/next/src/client/app-dir/link.tsx (TypeScript)

Code before:
        }
      } else if (key === 'transitionTypes') {
        if (props[key] != null && !Array.isArray(props[key])) {
          throw createPropError({
            key,
            expected: '`string[]`',
            actual: valType,
          })
        }
      } else {
        // TypeScript trick for type-guarding:
        const _: never = key
      }
    })
  }

  const resolvedHref = asProp || hrefProp
  const formattedHref = formatStringOrUrl(resolvedHref)

  if (process.env.NODE_ENV !== 'production') {
    if (transitionTypes && typeof React.addTransitionType !== 'function') {
      warnOnce(
        '`transitionTypes` are passed to a <Link>, but `React.addTransitionType` is not available. ' +
          'You need to enable `experimental.viewTransition` or `experimental.gestureTransition` to use Transition types.'
      )
    }
    if (props.locale) {
      warnOnce(
        'The `locale` prop is not supported in `next/link` while using the `app` router. Read more about app router internalization: https://nextjs.org/docs/app/building-your-application/routing/internationalization'
      )
    }
    if (!asProp) {
      let href: string | undefined
      if (typeof resolvedHref === 'string') {
        href = resolvedHref
      } else if (
        typeof resolvedHref === 'object' &&
        typeof resolvedHref.pathname === 'string'
      ) {
        href = resolvedHref.pathname
      }

      if (href) {
        const hasDynamicSegment = href
          .split('/')
          .some((segment) => segment.startsWith('[') && segment.endsWith(']'))

        if (hasDynamicSegment) {
          throw new Error(
            `Dynamic href \`${href}\` found in <Link> while using the \`/app\` router, this is not supported. Read more: https://nextjs.org/docs/messages/app-dir-dynamic-href`
          )

Review comment (suggestion):
@cursor This can be removed. `addTransitionType` is in Canary and therefore always available in Next.js App Router

Code after:
        }
      } else if (key === 'transitionTypes') {
        if (props[key] != null && !Array.isArray(props[key])) {
          throw createPropError({
            key,
            expected: '`string[]`',
            actual: valType,
          })
        }
      } else {
        // TypeScript trick for type-guarding:
        const _: never = key
      }
    })
  }

  const resolvedHref = asProp || hrefProp
  const formattedHref = formatStringOrUrl(resolvedHref)

  if (process.env.NODE_ENV !== 'production') {
    if (props.locale) {
      warnOnce(
        'The `locale` prop is not supported in `next/link` while using the `app` router. Read more about app router internalization: https://nextjs.org/docs/app/building-your-application/routing/internationalization'
      )
    }
    if (!asProp) {
      let href: string | undefined
      if (typeof resolvedHref === 'string') {
        href = resolvedHref
      } else if (
        typeof resolvedHref === 'object' &&
        typeof resolvedHref.pathname === 'string'
      ) {
        href = resolvedHref.pathname
      }

      if (href) {
        const hasDynamicSegment = href
          .split('/')
          .some((segment) => segment.startsWith('[') && segment.endsWith(']'))

        if (hasDynamicSegment) {
          throw new Error(
            `Dynamic href \`${href}\` found in <Link> while using the \`/app\` router, this is not supported. Read more: https://nextjs.org/docs/messages/app-dir-dynamic-href`
          )
        }
      }
    }
  }

  // This will return the first child, if multiple are provided it will throw an error