Valid `this` in server actions
maciej-ka opened this issue · 0 comments
maciej-ka commented
Link to the code that reproduces this issue
https://github.com/maciej-ka/next-server-action-valid-this
To Reproduce
npm run dev
- visit
Current vs. Expected behavior
Current
Expected
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:15 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6000
Available memory (MB): 65536
Available CPU cores: 10
Binaries:
Node: 22.9.0
npm: 10.8.3
Yarn: 1.22.17
pnpm: 9.15.0
Relevant Packages:
next: 15.0.4 // There is a newer version (15.1.2) available, upgrade recommended!
eslint-config-next: 15.1.2
react: 19.0.0
react-dom: 19.0.0
typescript: 5.7.2
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Vercel (Deployed), Other (Deployed)
Additional context
Debug
When debugging on Next.js version before forbidding this
(available on branch of reproduction repo)
export const createItem = async () => {
return new Promise<number>((resolve, reject) => {
console.dir(this);
db.run('INSERT INTO items (title) VALUES (?)', ["foo"], function(err) {
if (err) reject(err)
console.dir(this);
resolve(this.lastID)
})
});
};
Motivation
While the first case could be forbidden,
second case, where this
is a Statement
should be allowed.
Links
Forbidden this
introduced in: #73059
Ticket created from discussion: #74124
Solution PR by changing a function visitor: #74179