Skip to content

Commit 4c50c51

Browse files
acolytec3holgerd77gabrocheleau
authored
No more unerasable syntax (#3972)
* Remove all angle bracket type casting * Add new erasableSyntax job * rename ci job * add push trigger * add keys for `push` * remove angle brackets * skip build step * try to execute a block * Fix script * AI thinks this is more clever * redo script * Remove unerasable syntax * fix CI and testdata exports map * clean up ci job * Update .github/workflows/noCompile.yml Co-authored-by: Gabriel Rocheleau <[email protected]> --------- Co-authored-by: Holger Drewes <[email protected]> Co-authored-by: Gabriel Rocheleau <[email protected]>
1 parent 37e31ab commit 4c50c51

File tree

21 files changed

+115
-39
lines changed

21 files changed

+115
-39
lines changed

.github/workflows/noCompile.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: NoCompile
2+
on:
3+
workflow_call:
4+
inputs:
5+
dep-cache-key:
6+
required: true
7+
type: string
8+
workflow_dispatch:
9+
inputs:
10+
dep-cache-key:
11+
required: false
12+
default: 'none'
13+
push:
14+
branches:
15+
- master
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-noCompile
19+
cancel-in-progress: true
20+
21+
jobs:
22+
test-nocompile:
23+
runs-on: ubuntu-latest
24+
# Set default values for cache keys when triggered by push
25+
env:
26+
DEP_CACHE_KEY: ${{ github.event_name == 'push' && 'none' || inputs.dep-cache-key }}
27+
28+
steps:
29+
# We restore the code/deps from cache if triggered from workflow_call (i.e. have valid cache key)
30+
- if: env.DEP_CACHE_KEY != 'none'
31+
uses: actions/cache/restore@v4
32+
id: dep-cache
33+
with:
34+
path: ${{github.workspace}}
35+
key: ${{ env.DEP_CACHE_KEY }}
36+
37+
- name: Use Node.js 23
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: 23
41+
cache: 'npm'
42+
43+
- name: Install Dependencies (if not restored from cache)
44+
if: steps.dep-cache.outputs.cache-hit != 'true'
45+
run: npm ci --ignore-scripts
46+
working-directory: ${{ github.workspace }}
47+
48+
- run: node --conditions=typescript --experimental-strip-types examples/inlineClient.ts
49+
working-directory: ${{ github.workspace }}/packages/client
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { createCommonFromGethGenesis } from '@ethereumjs/common'
2+
import { eip4844GethGenesis } from '@ethereumjs/testdata'
3+
import { Config } from '../src/config.ts'
4+
import { createInlineClient } from '../src/util/inclineClient.ts'
5+
6+
const main = async () => {
7+
const client = await createInlineClient(
8+
new Config({}),
9+
createCommonFromGethGenesis(eip4844GethGenesis, {}),
10+
{},
11+
undefined,
12+
true,
13+
)
14+
await client.start()
15+
await client.stop()
16+
process.exit(0)
17+
}
18+
19+
main()

packages/client/src/net/peer/peer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ export abstract class Peer extends EventEmitter {
170170

171171
await bound!.handshake(sender)
172172

173-
this.eth = <BoundEthProtocol>bound
173+
this.eth = bound as BoundEthProtocol
174174
} else if (protocol.name === 'snap') {
175175
bound = new BoundSnapProtocol(boundOpts)
176176
if (sender.status === undefined) throw Error('Snap can only be bound on handshaked peer')
177177

178-
this.snap = <BoundSnapProtocol>bound
178+
this.snap = bound as BoundSnapProtocol
179179
} else {
180180
throw EthereumJSErrorWithoutCode(`addProtocol: ${protocol.name} protocol not supported`)
181181
}

packages/client/src/sync/fetcher/fetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ export abstract class Fetcher<JobTask, JobResult, StorageItem> extends Readable
483483
many: { chunk: Job<JobTask, JobResult, StorageItem>; encoding: string }[],
484484
cb: Function,
485485
) => {
486-
const items = (<Job<JobTask, JobResult, StorageItem>[]>[]).concat(
486+
const items = ([] as Job<JobTask, JobResult, StorageItem>[]).concat(
487487
...many.map(
488488
(x: { chunk: Job<JobTask, JobResult, StorageItem>; encoding: string }) => x.chunk,
489489
),

packages/client/test/sync/beaconsync.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe('[BeaconSynchronizer]', async () => {
120120
/// @ts-expect-error -- Assigning simpler config for testing
121121
sync.pool = { peers }
122122
sync['forceSync'] = true
123-
assert.equal(await sync.best(), <any>peers[1], 'found best')
123+
assert.equal(await sync.best(), peers[1] as any, 'found best')
124124
await sync.stop()
125125
await sync.close()
126126
})

packages/client/test/sync/fetcher/fetcher.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('should handle expiration', async () => {
7676
})
7777

7878
fetcher['in'].insert(job as any)
79-
;(<any>fetcher)['_readableState'] = []
79+
;(fetcher as any)['_readableState'] = []
8080
fetcher['running'] = true
8181
fetcher['total'] = 10
8282
fetcher.next()

packages/ethash/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ export class Miner {
9393

9494
if (solution) {
9595
if (this.block) {
96-
const data = <BlockData>this.block.toJSON()
96+
const data = this.block.toJSON() as BlockData
9797
data.header!.mixHash = solution.mixHash
9898
data.header!.nonce = solution.nonce
9999
return createBlock(data, { common: this.block.common })
100100
} else {
101-
const data = <HeaderData>this.blockHeader.toJSON()
101+
const data = this.blockHeader.toJSON() as HeaderData
102102
data.mixHash = solution.mixHash
103103
data.nonce = solution.nonce
104104
return createBlockHeader(data, { common: this.blockHeader.common })

packages/ethash/test/miner.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ describe('Miner', () => {
6565
{ common },
6666
)
6767
const miner = e.getMiner(block.header)
68-
const solution = <BlockHeader>await miner.mine(-1)
68+
const solution = (await miner.mine(-1)) as BlockHeader
6969

7070
assert.isTrue(
7171
await e.verifyPOW(createBlock({ header: solution.toJSON() }, { common })),
7272
'successfully mined block',
7373
)
7474

7575
const blockMiner = e.getMiner(block)
76-
const blockSolution = <Block>await blockMiner.mine(-1)
76+
const blockSolution = (await blockMiner.mine(-1)) as Block
7777

7878
assert.isTrue(await e.verifyPOW(blockSolution))
7979
}, 60000)
@@ -129,13 +129,13 @@ describe('Miner', () => {
129129
)
130130

131131
const miner = e.getMiner(block.header)
132-
const solution = <BlockHeader>await miner.mine(-1)
132+
const solution = (await miner.mine(-1)) as BlockHeader
133133

134134
assert.equal(solution.common.hardfork(), Hardfork.Petersburg, 'hardfork did not change')
135135
assert.equal(solution.common.chainName(), 'mainnet', 'chain name did not change')
136136

137137
const blockMiner = e.getMiner(block)
138-
const blockSolution = <Block>await blockMiner.mine(-1)
138+
const blockSolution = (await blockMiner.mine(-1)) as Block
139139

140140
assert.equal(blockSolution.common.hardfork(), Hardfork.Petersburg, 'hardfork did not change')
141141
assert.equal(blockSolution.common.chainName(), 'mainnet', 'chain name did not change')

packages/evm/test/eips/eof-header-validation.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ await new Promise<void>((resolve, reject) => {
4141
}
4242
const name = path.parse(fileName).name
4343
describe(`EOF Header validation tests - ${name}`, async () => {
44-
const testData = JSON.parse(<string>content)
44+
const testData = JSON.parse(content as string)
4545
const evm = await getEVM()
4646
for (const key in testData) {
4747
it(`Test ${key}`, () => {

packages/testdata/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
"module": "dist/esm/index.js",
88
"exports": {
99
".": {
10-
"import": "./dist/esm/index.js",
10+
"import": {
11+
"typescript": "./src/index.ts",
12+
"default": "./dist/esm/index.js"
13+
},
1114
"require": "./dist/cjs/index.js"
1215
}
1316
},

0 commit comments

Comments
 (0)