Apollo-tooling: Typescript schema types: Semicolons after interfaces cause errors

Created on 1 Mar 2018  路  6Comments  路  Source: apollographql/apollo-tooling

Using apollo-codegen 0.18.8 and typescript 2.7.2, I get the following error from Typescript:

[ts] Statements are not allowed in ambient contexts.

The error is caused by the semicolon inserted after the interfaces in the schema.d.ts file, for example:
export interface InterfaceName { ... };

Is there any CLI option to avoid the generation of semicolons?

Most helpful comment

+1 manually deleting semicolon kills me.

All 6 comments

+1 manually deleting semicolon kills me.

Same here, with Typescript 2.6.2.

@lewisf Could we just remove the generator.print(';'); from here ? That should fix this issue, but I don't know the exact impact on previous typescript version.

@TiuSh I don't use Typescript on my day to day graphql repo. Can someone confirm that this is okay?

@lewisf After a little digging, it seams that Typescript interfaces should not be followed by semicolon (see https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md for more examples). I created a PR with the given fix and updated tests.

A funny workaround, I run prettier on the generated file to remove the semicolon ...

With the new TypeScript target in the Apollo CLI, semicolons are no longer added after interfaces!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fenech picture fenech  路  3Comments

arthens picture arthens  路  3Comments

clayne11 picture clayne11  路  3Comments

viridia picture viridia  路  3Comments

rasmusprentow picture rasmusprentow  路  3Comments