schemats: Some characters are missing in generated output

Nodejs : 7.4.0 Postgres : 9.6.1 schemats : 1.0.1

While using last version 1.0.1 of this module, I run into a strange bug : in the generated file, some characters are missing, always in the third line of first interface declaration.

Eg, in the following example, the file contains export type sal_matriculetring; instead of export type sal_matricule = string; 4 characters = s are missing

Excerpt of output :

/**
 * AUTO-GENERATED FILE @ 2017-01-24 13:27:02 - DO NOT EDIT!
 *
 * This file was generated with schemats node package:
 * $ schemats generate -c postgres://username:password@localhost:5432/testpayroll -t pay_salarie_sal -o schema.ts
 *
 * Re-run the command above.
 *
 */

    
export namespace pay_salarie_salFields {
    export type sal_id = number;
    export type sal_matriculetring;

With another table, the missing characters are in nearly the same place :

/**
 * AUTO-GENERATED FILE @ 2017-01-24 13:33:18 - DO NOT EDIT!
 *
 * This file was generated with schemats node package:
 * $ schemats generate -c postgres://username:password@localhost:5432/testpayroll -t pay_contrat_cnt -o schema.ts
 *
 * Re-run the command above.
 *
 */

    
export namespace pay_contrat_cntFields {
    export type cnt_soldetc_mdp_id = number | null;
    exporte tex_id = number | null;

Of course, expected : export type tex_id instead of exporte tex_id 4 characters typ are missing

It’s the only issue in the output file : all other lines are correct.

I don’t reproduce the issue with osm artifact test file, which is weird.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 21 (20 by maintainers)

Commits related to this issue

Most upvoted comments

Thank you everyone, the patch is merged to typescript-formatter. Closing this issue with the release v1.1.2

Maybe we can receive some help of its author @vvakame I’ve created an issue there https://github.com/vvakame/typescript-formatter/issues/74

@abenhamdine Thanks. This is very helpful in reproducing it.

I can confirm If I disable typescript-formatter, by replacing index.ts

    let formatterOption = {
        replace: false,
        verify: false,
        tsconfig: true,
        tslint: true,
        editorconfig: true,
        tsfmt: false
    }

    const processedResult = await processString('schema.ts', output, formatterOption)
    return processedResult.dest

with simply return output

The generated file will have export type sco_total_debit = number; generated correctly. This is a weird issue and certainly suggests a bug in typescript-formatter (or a misusage of it in my part.) We use typescript-formatter to (mainly) generate files with correct indentation levels specified by the project’s tslintrc or editorconfig.

After some lengthy debug on typescript-formatter, I proposed a fix here https://github.com/vvakame/typescript-formatter/pull/75. I’ll release a fix for schemats quickly by pointing the typescript-fromatter version to our fork.