typescript-generator icon indicating copy to clipboard operation
typescript-generator copied to clipboard

Add support for controlled trailing semi-colons and injecting custom properties

Open manikandan-ravikumar opened this issue 4 months ago • 4 comments

In this PR, I would like to introduced the following two new settings,

  1. disableTrailingSemiColon - A boolean flag indicating if the generator should append every line with a semi-colon
  2. injectCustomProperties - A map of class to string property lists. Similar to importDeclarations but instead injects additional properties into the given type. This is useful for when we try to be backward-compatible in the FE API and update the backend logic to have the newer property names. Also avoids adding these properties manually every time after running the typscript-generator.

This PR also includes some minor improvements in other parts of the code.

manikandan-ravikumar avatar Apr 22 '24 10:04 manikandan-ravikumar

@manikandan-ravikumar Could you please elaborate on the reasons for disableTrailingSemiColon?

panchenko avatar Apr 22 '24 11:04 panchenko

@panchenko I am not disabling semi-colons. I am just introducing an option to disable it. The default value for disabling semi-colon is false. The reason behind this is, not all typescript projects use the trailing semi-colon pattern as with JavaScript/Typescript semi-colons are optional. Providing an option to disable it will avoid unnecessary manual work.

manikandan-ravikumar avatar Apr 22 '24 11:04 manikandan-ravikumar

The reason behind this is, not all typescript projects use the trailing semi-colon pattern as with JavaScript/Typescript semi-colons are optional. Providing an option to disable it will avoid unnecessary manual work.

I am trying to understand why it matters. Code analysis should be just disabled for the generated file. For example, in the file header there are comments to disable tslint/eslint.

panchenko avatar Apr 22 '24 12:04 panchenko

The reason behind this is, not all typescript projects use the trailing semi-colon pattern as with JavaScript/Typescript semi-colons are optional. Providing an option to disable it will avoid unnecessary manual work.

I am trying to understand why it matters. Code analysis should be just disabled for the generated file. For example, in the file header there are comments to disable tslint/eslint.

I agree from the functional POV. But from code maintenance POV, it makes this file stand-out. I am working in a project where we maintain a common standard across the code base and it involves no semi-colon usage. So, we had to generate.ts and make manual changes on top of it every time. This breaks the concept of having a "generated" file.

manikandan-ravikumar avatar Apr 22 '24 14:04 manikandan-ravikumar