Skip to content

Conversation

SergeAstapov
Copy link
Contributor

@SergeAstapov SergeAstapov commented Feb 22, 2021

We started integrating TypeScript into existing application and stumbled upon custom transform.

https://docs.ember-cli-typescript.com/ember-data/models wasn't much helpful so I followed https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50328/files and had to add interface to TransformRegistry to make TypeScript happy:

declare module 'ember-data/types/registries/transform' {
  export default interface TransformRegistry {
    point: PointTransform;
  }
}

after that everything started to work as expected.

I know the prose is really bad but could not came up with anything better. Maybe we can collectively iterate over the prose if the snippets are good here.

@SergeAstapov
Copy link
Contributor Author

Is this actually right/recommended way of extending TransformRegistry? Should we instead recommend to define these via types/registries/transform.d.ts like

export default interface TransformRegistry {
  point: PointTransform;
}

I'm new to ember-cli-typescript so would love to be guinea pig and test existing docs and identify what is missing

@chriskrycho
Copy link
Member

Hi @SergeAstapov – thanks so much for this! I apologize I missed it when it came through; I need to tweak my notifications settings here. I'll try to review it on Friday!

@SergeAstapov
Copy link
Contributor Author

SergeAstapov commented Mar 19, 2021

Thank you @chriskrycho! I updated PR to use more complex example with custom data structure. Please advice if this is not the canonical/suggested way of doing transforms, would love to hear back.

@chriskrycho
Copy link
Member

@jamescdavis mind taking a look at this? You’re more up-to-date and well-informed on Ember Data than I am!

@chriskrycho chriskrycho merged commit eae2261 into typed-ember:master Feb 4, 2022
@chriskrycho
Copy link
Member

I just went ahead and merged this; can iterate later! Thanks @SergeAstapov!

@SergeAstapov SergeAstapov deleted the docs-transform branch February 4, 2022 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants