From 15a63c4bc5e05583d15910a562d524ca9b1e4b9d Mon Sep 17 00:00:00 2001 From: "F. Eugene Aumson" Date: Wed, 13 Jun 2018 23:09:59 -0400 Subject: 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 = {}, 78: ): Promise { 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. --- packages/contract_templates/partials/params.handlebars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/contract_templates/partials/params.handlebars') 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}} -- cgit