Skip to content

Commit

Permalink
Workspace fixes and more
Browse files Browse the repository at this point in the history
  • Loading branch information
kaleidawave committed Jan 5, 2024
1 parent 1aa77e2 commit ad6b0e2
Show file tree
Hide file tree
Showing 15 changed files with 194 additions and 55 deletions.
31 changes: 25 additions & 6 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: GitHub release

on:
workflow_dispatch
on:
workflow_dispatch:
inputs:
ezno-version:
description: "Semver for Ezno (CLI) to release on"
required: false
default: "latest"

env:
CACHE_PATHS: |
Expand All @@ -23,12 +28,23 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-tags: true

- name: Get version
id: get-version
run: |
tag=$(git for-each-ref --sort=creatordate --format '%(refname:short)' 'refs/tags/release/ezno-[0-9]*' | tail -n 1)
echo "Releasing ${tag:13}"
echo "new-ezno-version=${tag:13}" >> $GITHUB_OUTPUT
if [ ${{ inputs.ezno-version }} = 'latest' ]; then
echo "::group::Ezno tags"
git for-each-ref --sort=creatordate --format '%(refname:short)' 'refs/tags/release/ezno-[0-9]*'
echo "::endgroup"
TAG=$(git for-each-ref --sort=creatordate --format '%(refname:short)' 'refs/tags/release/ezno-[0-9]*' | tail -n 1)
echo "Releasing ${TAG:13}"
echo "new-ezno-version=${TAG:13}" >> $GITHUB_OUTPUT
else
VERSION="${{ inputs.ezno-version }}"
echo "Releasing ${VERSION}"
echo "new-ezno-version=${VERSION}" >> $GITHUB_OUTPUT
fi
- id: get-sponsors
run: |
Expand Down Expand Up @@ -81,7 +97,10 @@ jobs:
- name: Rename and move release assets
run: |
mkdir artifacts
mv target/release/ezno${{ matrix.executable-extension }} artifacts/ezno-${{ needs.get-build-info.outputs.new-ezno-version }}-${{ matrix.platform_name }}${{ matrix.executable-extension }}
# Replace '.' with '-'
VERSION=$(echo "${{ needs.get-build-info.outputs.new-ezno-version }}" | sed -e "s/\./-/g")
NEW_PATH="artifacts/ezno-$VERSION-${{ matrix.platform_name }}${{ matrix.executable-extension }}"
mv target/release/ezno${{ matrix.executable-extension }} $NEW_PATH
- uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/performance-and-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Performance and size
on:
push:
branches: [main]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
ezno-version:
description: "major/minor/patch or semver for Ezno (cli)"
description: "major/minor/patch or semver for Ezno (CLI)"
required: false
default: "none"
ezno-checker-version:
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
- id: set-arguments
run: |
KEY_PAIR_ARGS="ezno=${{ github.event.inputs.ezno-version }},ezno-parser=${{ github.event.inputs.ezno-parser-version }},ezno-checker=${{ github.event.inputs.ezno-checker-version }},${{ github.event.inputs.other-versions }}"
KEY_PAIR_ARGS="ezno=${{ inputs.ezno-version }},ezno-parser=${{ inputs.ezno-parser-version }},ezno-checker=${{ inputs.ezno-checker-version }},${{ inputs.other-versions }}"
echo "::debug::$KEY_PAIR_ARGS"
Expand Down Expand Up @@ -89,17 +89,17 @@ jobs:
SPONSORS: ${{ steps.get-sponsors.outputs.sponsors }}

- name: Add WASM to rustup
if: ${{ github.event.inputs.ezno-version != 'none' }}
if: ${{ inputs.ezno-version != 'none' }}
run: rustup target add wasm32-unknown-unknown

- uses: brndnmtthws/rust-action-cargo-binstall@v1
if: ${{ github.event.inputs.ezno-version != 'none' }}
if: ${{ inputs.ezno-version != 'none' }}
with:
packages: [email protected]

- name: Set NPM package version & build
id: set-npm-version
if: ${{ github.event.inputs.ezno-version != 'none' }}
if: ${{ inputs.ezno-version != 'none' }}
run: |
VERSION=$(echo '${{ steps.release.outputs.new-versions-json-object }}' | jq -r '.ezno')
echo "new-ezno-version=${VERSION}" >> $GITHUB_OUTPUT
Expand All @@ -113,15 +113,15 @@ jobs:
env:
SPONSORS: ${{ steps.get-sponsors.outputs.sponsors }}

- name: NPM publish (cli and library)
if: ${{ github.event.inputs.ezno-version != 'none' }}
- name: NPM publish (CLI and library)
if: ${{ inputs.ezno-version != 'none' }}
uses: rxfork/npm-publish@v1
with:
token: ${{ secrets.NPM_REGISTRY_TOKEN }}
package: src/js-cli-and-library/package.json

- name: Update JS plugin version and dependencies
if: ${{ github.event.inputs.ezno-version != 'none' }}
if: ${{ inputs.ezno-version != 'none' }}
run: |
# Hopefully propagated in 20 seconds
sleep 20
Expand All @@ -141,8 +141,8 @@ jobs:
git add .
git commit -m "Release: ${{ steps.release.outputs.new-versions-description }}"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Create tags
echo '${{ steps.release.outputs.new-versions }}' | jq -r '.[]' | while read -r update; do
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ If you want to check all the checker tests

```shell
cargo test -p ezno-checker-specification
# Also
# To including staging.md (which is really useful for keeping new fixes/additions separate)
cargo test -p ezno-checker-specification -F staging
# and
# and for all the tests (which includes all of to_implement.md)
cargo test -p ezno-checker-specification -F all
```

Expand Down
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ members = [
"parser/generator",
"checker",
"checker/binary-serialize-derive",
"checker/specification",
# "lsp/server",
# "checker/specification"
]


Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
A JavaScript compiler and TypeScript checker written in Rust with a focus on static analysis and runtime performance.

> [!IMPORTANT]
> Ezno is in active development and **currently does not support enough features to check existing projects**. Check out the [getting started guide](./checker/docs/getting-started.md) for experimenting with what it currently [supports today](./checker/specification/specification.md).
Read about Ezno
- [Introducing Ezno](https://kaleidawave.github.io/posts/introducing-ezno/)
- [Ezno in '23](https://kaleidawave.github.io/posts/ezno-23/)
- [A preview of the checker](https://kaleidawave.github.io/posts/a-preview-of-the-checker/)
> Ezno is in active development and **currently does not support enough features to check existing projects**. Check out the [getting started guide](./checker/docs/getting-started.md) for experimenting with what it [currently supports](./checker/specification/specification.md).
<!-- Currently out ![project lines of code](https://projects.kaleidawave.workers.dev/project/ezno/badge) -->

What Ezno is
- A type checker for JavaScript, usable as a library or with *optional* compiler infrastructure (parser, CLI, LSP, etc)
- Fully typed programs with guaranteed type safety (as long as definitions are sound)
- A type checker for JavaScript usable through a CLI ([with a LSP also in the works](https://github.com/kaleidawave/ezno/issues/22))
- [A high level library](https://docs.rs/ezno-checker/latest/ezno_checker/) that allows [type checking to be added to other tools!](https://github.com/web-infra-dev/oxc/tree/main/crates/oxc_type_synthesis)
- Checks programs with guaranteed type safety (no runtime [`TypeError`s](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError)) (**as long as definitions are sound**)
- Types aimed at soundness and tracing for better static analysis
- A *imperative* type system that tracks and evaluates the side effects of functions and control flow structures. It is similar to an interpreter, but acts with types instead of *values*
- A *imperative* type system that tracks and evaluates the side effects of functions and control flow structures. It is similar to an interpreter, but acts with types instead of *values* and does not run IO side effects etc
- A collection of experiments of types. Many are being worked out and are in the prototype stage. Some of the new behaviors benefit JavaScript specifically and others could be applied to other languages
- A challenge to the status quo of type checking, optimisations and compilation through deeper static analysis beyond syntax analysis
- [A high level library](https://docs.rs/ezno-checker/latest/ezno_checker/) that allows [type checking to be added to other tools!](https://github.com/web-infra-dev/oxc/tree/main/crates/oxc_type_synthesis)
- [Fast](https://github.com/kaleidawave/ezno/actions/workflows/performance-and-size.yml)
- Written in Rust
- [**Efficient**](https://kaleidawave.github.io/posts/a-preview-of-the-checker/#checking-performance)

What Ezno is not
- **eNZo, the Z is in front of the N** (pronounce as 'Fresno' without the 'fr') 😀
- Be on parity with TSC or 1:1, it has some different behaviors **but** should work in existing projects using TSC (check out [stc](https://github.com/dudykr/stc) that is written in Rust and is aimed at replicating TSC)
- A binary executable generator. It takes in JavaScript (or a TypeScript or Ezno superset) and does similar processes to traditional compilers, but at the end emits JavaScript. However in the future it could generate a lower level format using its event representation
- A binary executable compiler. It takes in JavaScript (or a TypeScript or Ezno superset) and does similar processes to traditional compilers, but at the end emits JavaScript. However in the future it could generate a lower level format using its event (side-effect) representation

Read more about Ezno
- [Introducing Ezno](https://kaleidawave.github.io/posts/introducing-ezno/)
- [Ezno in '23](https://kaleidawave.github.io/posts/ezno-23/)
- [A preview of the checker](https://kaleidawave.github.io/posts/a-preview-of-the-checker/)

---

Expand Down
4 changes: 0 additions & 4 deletions checker/specification/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

# Prevent this from interfering with workspaces
[workspace]
members = ["."]

[features]
just-staging = []
staging = []
Expand Down
134 changes: 121 additions & 13 deletions checker/specification/to_implement.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
These tests do not pass ATM. But hopefully will in the future 🤞

### Types

#### Resolving value by property on dependent
Expand All @@ -14,19 +16,6 @@ getProperty("c") satisfies 2
- Expected "a" | "b" | "c" found "d"
- Expected 2 found 3

#### Set property on dependent observed

```ts
function add_property(obj: { prop: number }) {
obj.prop = 2;
(obj.prop satisfies 4);
}
```

> Not number
- Expected 4, found 2

#### Generic type argument restriction

```ts
Expand Down Expand Up @@ -401,6 +390,101 @@ array2[2] satisfies string;

- Expected string, found 3

#### Destructuring assign

> TODO include an object destructure here
```ts
let array1 = [1, 2, 3];
let a = 0, b = 0;
[a, b] = array1;

a satisfies 1;
b satisfies "hello world";
```

- Expected "hello world", found 2

#### Optional interface property

> TODO needs `Logical`-ish `PropertyValue`
```ts
declare const global: { a?: string };

("a" in global) satisfies string;
(global.a) satisfies 2;
```

- Expected string, found boolean
- Expected 2, found string | undefined

#### Delete from required propertied

```ts
declare let global: { a?: string, b: string };

// Fine
delete global.a;
// Bad
delete global.b;
```

- Cannot delete property "b" off { a?: string, b: string }

#### Try-catch variable restriction

```ts
try {
throw 2;
} catch (e: string) {
// ...
}
```

- Thrown type 2, not assignable to catch variable of string

#### `typeof` expression

> TODO better test
```ts
(typeof "hello") satisfies "string";
(typeof 5) satisfies "number";
(typeof {}) satisfies "Number";
```

- Expected "Number", found "object"

#### `instanceof` expression

```ts
class X {}
class Y {}

(new X instanceof X) satisfies number;
(new X instanceof Y) satisfies false;
```

- Expected number, found true

### Runtime

```ts
let x: number = 0;

document.addEventListener("click", () => {
x++;
});

document.addEventListener("scroll", () => {
x satisfies 0;
x++;
})
```

- Expected 0, found number

### Classes

#### Extends
Expand All @@ -414,6 +498,8 @@ const b = new BaseClass;
print_type(b.x);
```

- TODO

#### Privacy

```ts
Expand Down Expand Up @@ -450,6 +536,18 @@ print_type(x(90))

- TODO

#### No loop

```ts
function call(cb: () => void) {
return cb()
}

call(call)
```

- TODO hopefully doesn't blow up

### Function checking

#### Default parameter side effect on parameter
Expand All @@ -466,3 +564,13 @@ doThing(6, 1) satisfies 6;
```

- Expected 2, found 5

#### Default parameter type check

```ts
function doThing(b: number = "hello") {
return a
}
```

- Default value "hello" is not assignable to parameter of type number
Loading

0 comments on commit ad6b0e2

Please sign in to comment.