Skip to content

Conversation

salisbury-espinosa
Copy link

append readonly (string | Raw)[] to column type of ReturningMethod

append `readonly (string | Raw)[]` to column type of ReturningMethod
@lehni
Copy link
Collaborator

lehni commented May 4, 2025

@salisbury-espinosa Just to understand, what situation does this change solve?

@salisbury-espinosa
Copy link
Author

salisbury-espinosa commented May 27, 2025

@salisbury-espinosa Just to understand, what situation does this change solve?

@lehni
model with readonly idColumn (see issue and PR ):

export default class SomeModel extends Model {
   static get idColumn() {
    return ['id'] as const;
  }
}

some logic:

 const insertedRow = await SomeModel.query()
    .insert(data)
    .returning(SomeModel.idColumn);

typecheck generates an error

=>

TS2345: Argument of type readonly ['id'] is not assignable to parameter of type string | Raw | (string | Raw)[]
The type readonly ['id'] is readonly and cannot be assigned to the mutable type (string | Raw)[]

this patch fixes it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants