-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
es2020 target in tsc to allow bigint literal (#176)
* es2020 target in tsc to allow bigint literal * set module resolution for es2020 target * add a test Co-authored-by: near-bulldozer[bot] <73298989+near-bulldozer[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1db2e87
commit 2e9e197
Showing
7 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Worker } from 'near-workspaces'; | ||
import test from 'ava'; | ||
|
||
|
||
test.before(async t => { | ||
// Init the worker and start a Sandbox server | ||
const worker = await Worker.init(); | ||
|
||
// Prepare sandbox for tests, create accounts, deploy contracts, etx. | ||
const root = worker.rootAccount; | ||
|
||
// Deploy the test contract. | ||
const typescriptContract = await root.devDeploy( | ||
'build/typescript.wasm', | ||
); | ||
await typescriptContract.call(typescriptContract, 'init', {}) | ||
|
||
// Test users | ||
const ali = await root.createSubAccount('ali'); | ||
|
||
// Save state for test runs | ||
t.context.worker = worker; | ||
t.context.accounts = { root, typescriptContract, ali }; | ||
}); | ||
|
||
test.after(async t => { | ||
await t.context.worker.tearDown().catch(error => { | ||
console.log('Failed to tear down the worker:', error); | ||
}); | ||
}); | ||
|
||
|
||
test('bigint', async t => { | ||
const { typescriptContract } = t.context.accounts; | ||
let r = await typescriptContract.view('bigint', ''); | ||
t.is(r, "3"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { | ||
NearContract, | ||
NearBindgen, | ||
view, | ||
} from 'near-sdk-js' | ||
|
||
@NearBindgen | ||
class TypeScriptTestContract extends NearContract { | ||
@view | ||
bigint() { | ||
// JSON.stringify cannot seriaize a BigInt, need manually toString | ||
return (1n + 2n).toString() | ||
} | ||
|
||
default() { | ||
return new TypeScriptTestContract() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"experimentalDecorators": true, | ||
"target": "es2020", | ||
"noEmit": true | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
], | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.