json-schema-to-typescript icon indicating copy to clipboard operation
json-schema-to-typescript copied to clipboard

Fix strictIndexSignature with standalone types

Open mrcljx opened this issue 3 years ago • 0 comments

Removes the safe-naming reapplication against generateType return values which might cause invalid typescript definition files when strictIndexSignature is used.

interface MyInterface {
- [k: string]: LeafUndefined; // error TS2304: Cannot find name 'LeafUndefined'.
+ [k: string]: Leaf | undefined;
}

Please let me know if you think a different codepath needs to be fixed. But to me it looks like generateType calls generateRawType which already has:

  if (hasStandaloneName(ast)) {
    return toSafeString(ast.standaloneName)
  }

mrcljx avatar Nov 17 '21 07:11 mrcljx