aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract_templates
diff options
context:
space:
mode:
authorF. Eugene Aumson <gene@aumson.org>2018-06-14 11:09:59 +0800
committerF. Eugene Aumson <gene@aumson.org>2018-06-15 01:51:18 +0800
commit15a63c4bc5e05583d15910a562d524ca9b1e4b9d (patch)
tree91fe5993bad803a8025e31b3f487eefc827c91a6 /packages/contract_templates
parent4a2e4d2b55c89c91cebf434570feee91ccc449fa (diff)
downloaddexon-sol-tools-15a63c4bc5e05583d15910a562d524ca9b1e4b9d.tar
dexon-sol-tools-15a63c4bc5e05583d15910a562d524ca9b1e4b9d.tar.gz
dexon-sol-tools-15a63c4bc5e05583d15910a562d524ca9b1e4b9d.tar.bz2
dexon-sol-tools-15a63c4bc5e05583d15910a562d524ca9b1e4b9d.tar.lz
dexon-sol-tools-15a63c4bc5e05583d15910a562d524ca9b1e4b9d.tar.xz
dexon-sol-tools-15a63c4bc5e05583d15910a562d524ca9b1e4b9d.tar.zst
dexon-sol-tools-15a63c4bc5e05583d15910a562d524ca9b1e4b9d.zip
workaround for TypeScript trailing comma bug
before this change, TypeScript compilation of the generated contract wrapper was giving me the following errors: $ abi-gen --abis 'build/contracts/*.json' --out build/types --template contract_templates/contract.handlebars --partials 'contract_templates/partials/*.handlebars' Found 7 partial templates Found 1 ABI files Processing: Migrations... Created: build/types/migrations.ts $ tsc build/types/migrations.ts(81,23): error TS1013: A rest parameter or binding pattern may not have a trailing comma. build/types/migrations.ts(108,23): error TS1013: A rest parameter or binding pattern may not have a trailing comma. build/types/migrations.ts(130,23): error TS1013: A rest parameter or binding pattern may not have a trailing comma. build/types/migrations.ts(146,25): error TS1013: A rest parameter or binding pattern may not have a trailing comma. build/types/migrations.ts(173,25): error TS1013: A rest parameter or binding pattern may not have a trailing comma. build/types/migrations.ts(195,25): error TS1013: A rest parameter or binding pattern may not have a trailing comma. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. Here is the generated code around the first error: 74: public setCompleted = { 75: async sendTransactionAsync( 76: completed: BigNumber, 77: txData: Partial<TxData> = {}, 78: ): Promise<string> { 79: const self = this as any as MigrationsContract; 80: const inputAbi = self._lookupAbi('setCompleted(uint256)').inputs; 81: [completed, 82: ] = BaseContract._formatABIDataItemList(inputAbi, [completed, 83: ], BaseContract._bigNumberToString.bind(self)); All of the other errors are the same, a destructuring assignment with a single element but with a trailing comma. This is legal JavaScript but it is not allowed by the TypeScript compiler, apparently per the bug described at https://github.com/Microsoft/TypeScript/issues/24628 . While awaiting the 3.0 version of TypeScript, it's a simple enough change to have the template not append a trailing comma.
Diffstat (limited to 'packages/contract_templates')
-rw-r--r--packages/contract_templates/partials/params.handlebars2
1 files changed, 1 insertions, 1 deletions
diff --git a/packages/contract_templates/partials/params.handlebars b/packages/contract_templates/partials/params.handlebars
index ac5d4ae85..2d9bb8ed9 100644
--- a/packages/contract_templates/partials/params.handlebars
+++ b/packages/contract_templates/partials/params.handlebars
@@ -1,3 +1,3 @@
{{#each inputs}}
-{{name}},
+{{name}}{{#if @last}}{{else}},{{/if}}
{{/each}}