Skip to content

TypeScript type errors - inlining of whereClauses in subtypes #207

Description

@rc-oxpop

Hi! As part of the hackathon I'd like to play around with this model in TypeScript. LinkML has a generator for TypeScript types and interfaces:

gen-typescript .\model\ars_ldm.yaml > model/ars_ldm.ts

but the resulting code (via TypeScript Playground) has a few type mismatch errors.

The reason for this seems to be that in the generated interface WhereClauseCompoundExpression, the whereClauses property has been inlined (and hence has type WhereClause[] in the output TS), whereas in CompoundSetExpression and CompoundGroupExpression, it's not inlined, and so the whereClauses properties there have types which are aliases of string[] (i.e. they're lists of ids).

I think this is because in CompoundSetExpression and CompoundGroupExpression, the whereClauses slot usage is overridden to have inlined: false, whereas in general, where_clauses is inlined (necessarily, since WhereClause has no identifier). Setting the whereClauses slots for CompoundSetExpression and CompoundGroupExpression to be inlined as lists fixes the type errors in the generated TypeScript.

Would inlining the whereClauses slots for those two classes cause problems anywhere else? Or is there a better fix somewhere? I'm happy to raise a PR to fix if you think appropriate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    T-shirt sizing

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions