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

[pull] main from dudykr:main #12

Merged
merged 33 commits into from
Dec 17, 2023
Merged

[pull] main from dudykr:main #12

merged 33 commits into from
Dec 17, 2023

Conversation

pull[bot]
Copy link

@pull pull bot commented Aug 9, 2023

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

**Description:**

implement `keyof this`
```ts
// @strict: true
// @declaration: true

type OldDiff<T extends keyof any, U extends keyof any> = (
    & { [P in T]: P; }
    & { [P in U]: never; }
    & { [x: string]: never; }
)[T];
interface A {
    a: 'a';
}
interface B1 extends A {
    b: 'b';
    c: OldDiff<keyof this, keyof A>;
}
type c1 = B1['c']; // 'c' | 'b'
```
**Description:**

```ts
// @strictNullChecks: true
// @declaration: true

enum E { A, B, C };

type K15 = keyof E;  // "toString" | "toFixed" | "toExponential" | ...
```
@github-actions
Copy link

github-actions bot commented Aug 9, 2023

Thank you for the PR!
Commit: 9fe5d43

Files to check

These are files which is affected by the current PR, but not reflected. If there's no file below this message, please ignore this message.

You can run ./scripts/auto-unignore.sh from crates/stc_ts_file_analyzer for typescript files, and ./scripts/check.sh from crates/stc_ts_type_checker for *.stats.rust-debug files.

@pull pull bot added the ⤵️ pull label Aug 9, 2023
sunrabbit123 and others added 25 commits August 10, 2023 12:28
**Description:**

```ts
// @strictNullChecks: true
// @declaration: true


class A<T> {
	props: T & { foo: string };
}

class B extends A<{ x: number}> {
	f(p: this["props"]) {
		p.x;
	}
}
```
**Description:**

```ts
function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K]) {
    x1 = x2;
    x1 = x3;
    x2 = x1;
    x2 = x3;
    x3 = x1;
    x3 = x2;
    x1.length;
    x2.length;
    x3.length;
}
```
**Description:**

When comparing TSC to error, we took the error results from ACTUAL.

In actual, the rules for each file were not applied properly,
As a result, tests like strictNullCheck didn't work correctly.

To fix this, we unified the env import code within the tests.
…1072)

**Description:**

```ts
function l<T extends {}, P extends keyof T>(s: string, tp: T[P]): void {
    tp = s;
}
```
**Description:**

```rs
 if r.is_num() {
      match src.parse() {
          Ok(v) => {
              return Type::Lit(LitType {
                  span,
                  lit: RTsLit::Number(RNumber { span, value: v, raw: None }),
                  metadata: Default::default(),
                  tracker: Default::default(),
              })
          }
          Err(..) => {
              return Type::Keyword(KeywordType {
                  span,
                  kind: TsKeywordTypeKind::TsNumberKeyword,
                  metadata: Default::default(),
                  tracker: Default::default(),
              })
          }
      }
  }
```
**Description:**

```ts
type A = 1 | 2;
function f<T extends A>(a: T): A & T { return a; } // Shouldn't error
```
…ndefined` (#1073)

**Description:**

```ts
function f10<T>(x: T, y: Partial<T>, k: keyof T) {
    x[k] = y[k];  // Error
    y[k] = x[k];
}
```
#1067)

**Description:**
```ts
function l<T extends {}, P extends keyof T>(s: string, tp: T[P]): void {
    tp = s;
}
function m<T extends { a: number }, P extends keyof T>(s: string, tp: T[P]): void {
    tp = s;
}
function f<T extends object, P extends keyof T>(s: string, tp: T[P]): void {
    tp = s;
}
```
**Description:**

```ts
type TBigInt2 = "0x10" extends `${infer N extends bigint}` ? N : never; // bigint (not round-trippable)
type TBigInt3 = "0o10" extends `${infer N extends bigint}` ? N : never; // bigint (not round-trippable)
type TBigInt4 = "0b10" extends `${infer N extends bigint}` ? N : never; // bigint (not round-trippable)
```
**Description:**

```ts
declare global { interface ImportMeta {foo?: () => void} };

if (import.meta.foo) {
  import.meta.foo();
}
```
**Description:**

```rs
let main_src = Arc::new(fs::read_to_string(file_name).unwrap());
// Postpone multi-file tests.
if main_src.contains("<reference path") {
    panic!("`<reference path` is not supported yet");
}
```
remove it for next

```tsx
/// <reference lib="dom" />
```

**Deep Dive**
this code wrote #487

I'm guessing it was used as a pass-through because it was a test case
that was too much for the code to handle at the time.
And I don't think it matters if you delete that code now.
AcrylicShrimp and others added 5 commits October 6, 2023 06:01
**Description:**

This PR implements checker behaviors for `wasm` binding. By supporting wasm, implementing playground will become very easy. I also implemented PoC of playground and it works well. I'll contribute on that when this PR is ready and merged.

Due to the constraints of wasm, there is a few APIs that should not be used. Below is the list.

- `std::time::Instant`
- `mimalloc_rust` from `swc_node_base`
- All file-system related APIs.

We dropped some code to avoid use of the APIs, and this PR contains those changes. I marked this PR as draft; we have to manage them somehow before merge it.

**Related issue:**

 - #300
 - #1021
**Description:**
```ts

declare module "foo2" {
    namespace Bar {
        interface I {
            a: string;
            b: number;
        }
    }

    namespace Baz {
        interface J {
            a: number;
            b: string;
        }
    }

    class Bar {
        item: Bar.I;
        constructor(input: Baz.J);
    }
}

let y: import("foo2").Bar.I = { a: "", b: 0 };
```
#1103)

**Description:**

```ts
interface I31<T> extends T { x: string }
```

I have a concern.

The following functions cause duplicate error handling due to duplicate
function calls.

```rs
#[validator]
impl Analyzer<'_, '_> {
    fn validate(&mut self, d: &RTsInterfaceDecl) -> VResult<Type> {
        let ty = self.with_child(ScopeKind::Flow, Default::default(), |child: &mut Analyzer| -> VResult<_> {
            match &*d.id.sym {
                "any" | "void" | "never" | "unknown" | "string" | "number" | "bigint" | "boolean" | "null" | "undefined" | "symbol" => {
                    child.storage.report(ErrorKind::InvalidInterfaceName { span: d.id.span }.into());
                }
                _ => {}
            }

            let mut ty = Interface {
                span: d.span,
                name: d.id.clone().into(),
                type_params: try_opt!(d.type_params.validate_with(&mut *child).map(|v| v.map(Box::new))),
                extends: d.extends.validate_with(child)?.freezed(),
                body: d.body.validate_with(child)?,
                metadata: Default::default(),
                tracker: Default::default(),
            };
            child.prevent_expansion(&mut ty.body);
            ty.body.freeze();

            child.resolve_parent_interfaces(&d.extends, true);
            child.report_error_for_conflicting_parents(d.id.span, &ty.extends);
            child.report_error_for_wrong_interface_inheritance(d.id.span, &ty.body, &ty.extends);

            let ty = Type::Interface(ty).freezed();

            Ok(ty)
        })?;

        // TODO(kdy1): Recover
        self.register_type(d.id.clone().into(), ty.clone());

        Ok(ty)
    }
}
```

`child.resolve_parent_interfaces` and
`child.report_error_for_wrong_interface_inheritance` call
`report_error_for_unresolved_type`
this fn cause `ErrorKind::TypeNotFound`

This PR only clogs the hole.

If there seems to be a need for fundamental improvement, please open up
the issue
@pull pull bot merged commit 34abe15 into Mu-L:main Dec 17, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants