-
Notifications
You must be signed in to change notification settings - Fork 38
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
Update target to es2024, use tsconfigs for typechecks, and run type checks at the top level (breaking changes) #2653
base: main
Are you sure you want to change the base?
Conversation
c79ff64
to
7a9509a
Compare
cbd7e61
to
ccd4b2b
Compare
e9ca70c
to
d6c84db
Compare
http_client/fetch_ic/call.ts
Outdated
@@ -126,7 +126,7 @@ async function prepareRequestBody( | |||
init.body instanceof Float32Array || | |||
init.body instanceof Float64Array | |||
) { | |||
return new Uint8Array(init.body); | |||
return new Uint8Array(init.body as ArrayBuffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's talk about this, if you just get rid of BigUint64Array and BigInt64Array in the union the error gets fixed. We should consider just doing that, and maybe this is some bug we should open an issue for somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should still file that issues somewhere?
.github/workflows/test.yml
Outdated
|
||
- run: npm run typecheck | ||
- run: npm run lint | ||
|
||
check-test-success: | ||
name: Check Azle tests succeeded | ||
needs: run-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we want top-level-checks to be hooked up here don't we? We need to make sure there's only pass or fail if run-tests and top-level-checks pass or fail...right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, done
src/lib/experimental/fetch/http.ts
Outdated
@@ -202,7 +202,7 @@ async function prepareRequestBody( | |||
|
|||
if (typeof init.body === 'string') { | |||
const textEncoder = new TextEncoder(); | |||
return [textEncoder.encode(init.body)]; | |||
return [textEncoder.encode(init.body) as Uint8Array<ArrayBuffer>]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's discuss these casts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes let's
src/lib/experimental/fetch/icp.ts
Outdated
@@ -61,7 +61,7 @@ export async function fetchIcp( | |||
} | |||
); | |||
|
|||
const decodedResult = IDL.decode(funcIdl.retTypes, result); | |||
const decodedResult = IDL.decode(funcIdl.retTypes, result.buffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really want to understand this. Let's discuss why this worked before, because it doesn't make sense to me fully why it would not continue to work.
@@ -21,8 +21,10 @@ export function isController(principal: Principal): boolean { | |||
} | |||
|
|||
if (globalThis._azleIcExperimental !== undefined) { | |||
const principalBytes = | |||
principal.toUint8Array() as Uint8Array<ArrayBuffer>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoa let's discuss this, I think there's a better way than these casts, I hope
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay let's discuss it
@@ -2,6 +2,7 @@ | |||
"compilerOptions": { | |||
"strict": true, | |||
"target": "ES2024", | |||
"module": "ES2022", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module and moduleResolution are being taken care of in another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ES022 now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because ES2022 is what we agreed on for module... I thought.
Yes module and module resolution are in a separate issue. Though es2022 is the one I am planning on using for that pr.
@@ -0,0 +1,8 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please help me to understand this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the package.json comment this is so that we can exclude all of the examples from the type checks. As long as we have to make a separate config for that I figured it would be good to add the other type checking settings like skipLibCheck and noEmit. We extend from the base tsconfig to make sure we use the same settings
@@ -3,7 +3,7 @@ | |||
"version": "0.25.0", | |||
"description": "TypeScript and JavaScript CDK for the Internet Computer", | |||
"scripts": { | |||
"typecheck": "tsc --noEmit", | |||
"typecheck": "tsc --project tsconfig.typecheck.json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please help me to understand this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to type check the examples at this point. I was figuring that we didn't want to exclude the examples in the main tsconfig.json because it already had an exclude property that was only excluding the new examples (which actually needs to be updated? or gotten rid of, because it's in a new location. (just let me know which one that is and I will do it, otherwise I will add it to the issue about making the ideal tsconfig (another option is that we actually do just exclude the examples in the main ts config? I'm not sure how that would play off extending the main one though...))). Unfortunately you cannot, to my knowledge, pass an ignore list as a parameter, only in the tsconfig.json. You can make another tsconfig and point it tsc to it as a separate project. This allows us to have one tsconfig for building and one for typechecking.
test/index.ts
Outdated
@@ -2,9 +2,14 @@ import * as dns from 'node:dns'; | |||
dns.setDefaultResultOrder('ipv4first'); | |||
|
|||
import { describe, expect, test } from '@jest/globals'; | |||
import { execSync } from 'child_process'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we using execSync?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have my reasons, but let's not worry about that, I'll just switch it to execSyncPretty
@@ -36,12 +41,11 @@ export function runTests( | |||
|
|||
if (shouldRunTypeChecks === true) { | |||
describe(`type checks`, () => { | |||
it('checks types', () => { | |||
it('checks types', async () => { | |||
const typeCheckCommand = `npm exec --offline tsc -- --noEmit --skipLibCheck`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we try to explicitly pass in the tsconfig.json of the project? Just like we do at the top level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, I felt like passing in at the top level was a work around we had to do because of the extra files we wanted to ignore. I think this is a much better method under normal circumstances
Contributor
Reviewer
Breaking Changes
Uint8Array
must use explicit<ArrayBuffer>
type argument instead of the default<ArrayBufferLike>
type argument