Commit Graph
9 Commits
Author SHA1 Message Date
d16d9f46b6 [TypeScript Plugin] Match method signature (someFunc(): void) type for client boundary warnings (#79144)
Best to be reviewed with "Hide whitespace".

### Why?

The props marked `(): any` bypassed the warning for non-serializable
props.

```tsx
'use client'

export function Comp({ onClick }: { onClick(): any }) {
  // ...
}
```

Added tests to prevent regression.

---------

Co-authored-by: Janka Uryga <[email protected]>
2025-05-20 01:35:51 +02:00
3ecf087f10 [TypeScript Plugin] Moved the diagnostics' positions to the prop's type instead of the value for client-boundary warnings (#79193)
Best be reviewed with "Hide whitespace".

### Why?

Since it was matching `ts.isObjectBindingPattern`, which checks only the
destructured props:

![CleanShot 2025-05-14 at 12 17
25@2x](https://github.com/user-attachments/assets/44aaffd2-9276-486e-86ce-acb77d488ab0)

It didn't handle non-destructured:

![CleanShot 2025-05-14 at 12 17
34@2x](https://github.com/user-attachments/assets/23abc130-3e17-4f72-89a2-bc084841f52f)

Therefore, I think it's more natural to target the types, not the props
value, as the cause of this warning is actually the types:

![CleanShot 2025-05-14 at 12 18
00@2x](https://github.com/user-attachments/assets/0a5a64c8-1ac9-4b0f-8fe7-20e78db2acec)

![CleanShot 2025-05-14 at 12 17
53@2x](https://github.com/user-attachments/assets/72008c25-7d7b-46e4-8e2f-e52f01e50b80)

x-ref:
https://github.com/vercel/next.js/pull/79144#discussion_r2086941435

---------

Co-authored-by: Janka Uryga <[email protected]>
2025-05-17 12:04:44 +02:00
Jiwon ChoiandGitHub 53bb899fc4 [ts-next-plugin] test: add client-boundary test (#79194)
This PR added tests for Next.js TypeScript plugins, specific for client-boundary. Updated the readme and removed the legacy fixture.
2025-05-15 11:39:26 +02:00
Jiwon ChoiandGitHub 0625d0d116 [ts-next-plugin] test: add metadata warn no type test (#78505)
### Why?

This PR initiates the migration of manual testing of the Next.js TypeScript plugin to an automated language service plugin test. It replaced the existing metadata `missing-type-warning` fixture with the `warn-no-type` test (naming for consistency, such as future `error-on-client`).

### Testing Plan

This PR adds the tests and fixtures for the metadata plugin to **warn when no type is provided** for metadata config exports (`metadata` and `generateMetadata`).

1. The fixtures are tested into two categories: 1) "**has type**": expects no warning, and 2) "**no type**": expects a warning.
2. For "has type", the types are from `next` or custom.
3. Each section consists of inline exports and separate exports (`export { ... }`).
4. For the fixtures of `generateMetadata`, it is divided into a function, an arrow function, and a function expression divided with sync and async.

<details><summary>Structure Details</summary>
<p>

#### `metadata`

```
.
├── has-type/
│   ├── export-inline/
│   │   ├── from-next
│   │   └── from-others
│   └── export-separate/
│       ├── from-next
│       └── from-others
└── no-type/
    ├── export-inline
    └── export-separate
```

#### `gerenateMetadata`

```
.
├── has-type/
│   ├── export-inline/
│   │   ├── from-next/
│   │   │   ├── async/
│   │   │   │   ├── arrow-function
│   │   │   │   ├── function-declaration
│   │   │   │   └── function-expression
│   │   │   └── sync/
│   │   │       ├── arrow-function
│   │   │       ├── function-declaration
│   │   │       └── function-expression
│   │   └── from-others/
│   │       ├── async/
│   │       │   └── ...
│   │       └── sync/
│   │           └── ...
│   └── export-separate/
│       ├── from-next/
│       │   ├── async/
│       │   │   └── ...
│       │   └── sync/
│       │       └── ...
│       └── from-others/
│           ├── async/
│           │   └── ...
│           └── sync/
│               └── ...
└── no-type/
    ├── export-inline/
    │   ├── async/
    │   │   └── ...
    │   └── sync/
    │       └── ...
    └── export-separate/
        ├── async/
        │   └── ...
        └── sync/
            └── ...
```

</p>
</details> 

### Follow Up

The metadata currently has one more feature: an error when using metadata exports within Client Components.
2025-05-12 13:52:28 +02:00
Jiwon ChoiandGitHub 34c5d411dc [ts-next-plugin] add testing utils (#79079)
Ported from https://github.com/vercel/next.js/pull/78505, this PR adds testing utils and a basic log test for the Next.js TypeScript language service plugin.
2025-05-12 13:20:18 +02:00
Jiwon ChoiandGitHub ec2923acc2 [ts-next-plugin] test: add metadata and generateMetadata fixtures (#78409)
This PR added test fixtures for the Next.js TypeScript plugin for
metadata. The test should be done manually at the moment and will be
followed up to improve testing, e.g.
https://github.com/vercel/next.js/pull/78254#pullrequestreview-2783491648
2025-04-23 17:32:54 +09:00
a9492ffa12 chore: update typescript document path (#72482)
## Description
At #72178,
[TypeScript](https://nextjs.org/docs/app/api-reference/config/typescript)
docs was moved.
So update the old URLs.

### Improving Documentation

- [x] Run `pnpm prettier-fix` to fix formatting issues before opening
the PR.
- [x] Read the Docs Contribution Guide to ensure your contribution
follows the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

---------

Co-authored-by: Zack Tanner <[email protected]>
2024-11-07 14:42:24 -08:00
Hendrik LiebauandGitHub 4e140370a8 Fix regression in TS plugin: allow reset prop in error files (#69777)
The TypeScript error `Props must be serializable for components in the
"use client" entry file, "reset" is invalid.` for the `reset` prop in
`error.tsx` and `global-error.tsx` was fixed in #46898 and #48756,
respectively. However, a regression of the fix was accidentally
introduced in #67211.

This PR restores the previous behavior and adds fixtures for manual
testing. (Since the Next.js TS plugin only applies to VSCode, manual
testing in VSCode is required. See
[`test/development/typescript-plugin/README.md`](https://github.com/vercel/next.js/blob/a5f30e68f8d1fe614965abc5df0234a869c6db8a/test/development/typescript-plugin/README.md)
for details.)
2024-09-17 13:37:26 +02:00
08da98dfbc TypeScript plugin: Allow functions in action-like props (#67211)
Co-authored-by: Delba de Oliveira <[email protected]>
2024-07-15 23:14:59 +02:00