Skip to content
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

feat(compiler): Handle TSSatisfiesExpression #29818

Closed
wants to merge 12 commits into from

Conversation

nikeee
Copy link
Contributor

@nikeee nikeee commented Jun 8, 2024

Summary

Resolves #29754

Details

I tried keeping @babel/types as low as possible, to match the actual used implementation. However, there were multiple issues:

  • Using <7.24 caused ~200 type errors
  • Using ^7.23 added AST support for optional member assignments, which are at stage 1. I added TODOs/"Not Supported" for these cases.
  • SourceLocation seems to now have identifiers, filename and index. It is used in scope merging. Since filename and identifier cannot be "merged", I chose the right location as the one supplying these, because the only usage of that function passes identifier for the right location. This might not be what we want, please check this and assume that I don't know what I am doing :)

How did you test this change?

Added a test for a simple case. I think we don't need a more complex one, since we're only interested in the inner expression and not in the satisfies constraint.

Copy link

vercel bot commented Jun 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ❌ Failed (Inspect) Jul 16, 2024 11:58am

@react-sizebot
Copy link

react-sizebot commented Jun 8, 2024

Comparing: c2ae9e2...a4b0ec0

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.66 kB 6.66 kB +0.11% 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 497.44 kB 497.44 kB = 89.16 kB 89.16 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.67 kB 6.67 kB +0.11% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 502.26 kB 502.26 kB = 89.85 kB 89.85 kB
facebook-www/ReactDOM-prod.classic.js = 596.94 kB 596.94 kB = 105.24 kB 105.24 kB
facebook-www/ReactDOM-prod.modern.js = 571.12 kB 571.12 kB = 101.19 kB 101.19 kB
test_utils/ReactAllWarnings.js Deleted 63.89 kB 0.00 kB Deleted 15.97 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
test_utils/ReactAllWarnings.js Deleted 63.89 kB 0.00 kB Deleted 15.97 kB 0.00 kB

Generated by 🚫 dangerJS against a4b0ec0

@nikeee
Copy link
Contributor Author

nikeee commented Jun 8, 2024

Still fighting with linter dependencies, converting to draft.

@nikeee nikeee marked this pull request as draft June 8, 2024 20:20
```ts
  // Returns `true` if the result is `Ok`.
  isOk(): this is OkImpl<T>;
  // Returns `true` if the result is `Err`.
  isErr(): this is ErrImpl<E>;
```

The implementations just return `boolean`, which seems to break in TS 5.5:

Running `tsc` in current `main`:
```
tsc
src/Utils/Result.ts:202:3 - error TS2416: Property 'isOk' in type 'ErrImpl<E>' is not assignable to the same property in base type 'Result<never, E>'.
  Type '() => boolean' is not assignable to type '() => this is OkImpl<never>'.
    Signature '(): boolean' must be a type predicate.

202   isOk(): boolean {
      ~~~~

src/Utils/Result.ts:206:3 - error TS2416: Property 'isErr' in type 'ErrImpl<E>' is not assignable to the same property in base type 'Result<never, E>'.
  Type '() => boolean' is not assignable to type '() => this is ErrImpl<E>'.
    Signature '(): boolean' must be a type predicate.

206   isErr(): boolean {

Found 38 errors in 7 files.

Errors  Files
     2  src/HIR/BuildHIR.ts:196
     2  src/HIR/Environment.ts:745
     2  src/ReactiveScopes/CodegenReactiveFunction.ts:290
    14  src/Utils/Result.ts:96
     2  src/Validation/ValidateNoRefAccesInRender.ts:201
     2  src/Validation/ValidateNoSetStateInRender.ts:115
    14  src/__tests__/Result-test.ts:13

```sh
tsc
tsc --version
Version 5.5.3
```
Copy link

This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.

@github-actions github-actions bot added the Resolution: Stale Automatically closed due to inactivity label Oct 14, 2024
@josephsavona
Copy link
Contributor

josephsavona commented Oct 14, 2024

Thank you for the contribution! I think we'll have to redo this one given the conflicts and issues with babel versioning.

@nikeee nikeee deleted the handle-satisfies-expression branch October 14, 2024 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Resolution: Stale Automatically closed due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Compiler Todo]: Handle TSSatisfiesExpression expressions
4 participants