grantila / typeconv

Convert between JSON Schema, TypeScript, GraphQL, Open API and SureType
MIT License
421 stars 8 forks source link

TS namespace #10

Closed myalban closed 1 year ago

myalban commented 3 years ago

Hi,

It seems there is no namespace support for typeconv Example, this file sample.ts output nothing export namespace ModelVersion { export interface Version { version: string; codename: string; id: string; } } Best regards

grantila commented 3 years ago

Hmm, the transformations goes through core-types and eventually into JSON Schema, OpenAPI or GraphQL, neither of which have namespaces.

What is the expected result here? To simply extract interfaces from the namespace and ignore the namespace in the output, or mangle the names somehow into e.g. ModelVersion_Version or ModelVersionVersion?

eastcoastcoder commented 2 years ago

It would be perfect for me if we could just ignore these namespaces completely (as in, don't skip the interfaces but no need to include the namespace in the output), or at least have that as a option.

const { data: doc } = convertTypeScriptToCoreTypes(tsFile, {
  namespace: 'ignore',
});
gerbal commented 1 year ago

I've opened a PR (core-types-ts#10) to add basic namespace handling. Since my target use case needs namespaces to differentiate identically named interfaces, I've elected to format namespaces like ModelVersion.Version, which works well with OAPI as the output target.

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 2.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: