Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

When converting from typescript to a target language, how can I declare a class as public?

未关闭
#2,012 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
swift, typescript
领域
tooling

调研方向

首先重现命令 quicktype ESLModels.ts -o CodeGenOutput.swift,并检查 issue 中显示的生成的 Swift 声明和辅助函数。确定 Swift 输出选项的处理方式,然后验证所请求的访问修饰符是否一致地出现在生成的文件中。

由索引模型根据 Issue 内容生成。

描述

When running this command quicktype ESLModels.ts -o CodeGenOutput.swift, I want the outputted file to contain public access modifiers. The output is technically correct, but if a project uses multiple packages, then we need these classes to have a public designation. In other words, enum ProcedureStateEnum needs to be public enum ProcedureStateEnum

ESLModels.ts

export enum ProcedureStateEnum {
    draft = 'draft',
    review = 'review',
    pending_approval = 'pending_approval',
    effective = 'effective',
    inactive = 'inactive',
    approved = 'approved',
    retired = 'retired',

    archived = 'archived',
}

outputs:

enum ProcedureStateEnum: String, Codable {
    case approved = "approved"
    case archived = "archived"
    case draft = "draft"
    case effective = "effective"
    case inactive = "inactive"
    case pendingApproval = "pending_approval"
    case retired = "retired"
    case review = "review"
}

// MARK: - Helper functions for creating encoders and decoders

func newJSONDecoder() -> JSONDecoder {
    let decoder = JSONDecoder()
    if #available(iOS 10.0, OSX 10.12, tvOS 10.0, watchOS 3.0, *) {
        decoder.dateDecodingStrategy = .iso8601
    }
    return decoder
}

func newJSONEncoder() -> JSONEncoder {
    let encoder = JSONEncoder()
    if #available(iOS 10.0, OSX 10.12, tvOS 10.0, watchOS 3.0, *) {
        encoder.dateEncodingStrategy = .iso8601
    }
    return encoder
}
主要语言
TypeScript
星标
13.9k
派生
1.2k
平均合并
8 小时 14 分钟
30 天内合并 PR
368

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

glideapps/quicktype 的其他 Issue

查看 glideapps/quicktype 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。