RicoSuter / NJsonSchema

JSON Schema reader, generator and validator for .NET
http://NJsonSchema.org
MIT License
1.39k stars 534 forks source link

Typescript interface naming inconsistancy #555

Open shapel opened 6 years ago

shapel commented 6 years ago

Hello

Look like system has inconsistency in typescript interface naming.

In case TypeStyle=Class according to Class.liquid interface name will be generated with I at the beginning, (what's good practice according to https://palantir.github.io/tslint/rules/interface-name/) in case TypeStyle=Interface according to Interface.liquid interface name will be generated without I at the beginning.

RicoSuter commented 6 years ago

According to the TypeScript coding guidelines, interface should not start with I:

Do not use "I" as a prefix for interface names.

https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#names

This is why we generate the interfaces without I when TypeStyle=Interface. When TypeStyle=Class then the main class is generated without I and the "helper" interface with I because it cannot be generated with the same name...

shapel commented 6 years ago

As you know, link you provided "are mainly meant for contributors to the TypeScript project." Can this behavior be parameterized? Because by default tslint expect I prefix ( https://github.com/palantir/tslint/blob/master/src/configs/recommended.ts#L55 ) and this can break linting or worse expectations of interfaces usage through the whole solution which used generated client.

shapel commented 6 years ago

Also I can share with you (in separate issue) what in the current implementation of generated classes made me try to use TypeStyle=Interface.