-
-
Notifications
You must be signed in to change notification settings - Fork 87
Interest in TypeScript? #346
Comments
Hmm, yeah, that would be interesting. I know almost nothing about TypeScript though, or the pitfalls of converting an Ember addon. Which would you suggest? Providing a type definition or just converting the addon over? |
The easiest starting point would be to add the type definitions. Converting the addon over requires a substantial amount of time, whereas the quickest gains (for users) would be provided with the typings already. If you're interested I can have a go at a PR for adding those typings to this repo? |
Sure thing. Would TypeScript users just "magically" get type information with the definition being part of the repo? Also, is there a process around ensuring the types are up-to-date? My concern with external type definitions is only that it becomes something to remember whenever the API changes. OTOH this is really not much an issue since this addon will likely never see a major API change; I pretty actively encourage people to avoid this addon and use |
👋 TS users will just get type info with the definition living in the repository. Even better, having them ship with the addon means that JS users will get code completion and any documentation attached to the type definitions if their editor supports it (and everything from Vim to IntelliJ idea does!). The ember-cli-typescript team will be happy to help check the type definitions and make sur ethey’re right! |
Sweet. Let's do this, then! Let me know if there's anything on my end that can be done to improve the TypeScript experience. |
I've been converting a bunch of my addons to TypeScript lately and enjoying it, so I'm actually looking into just converting the addon entirely instead of just adding a type definition. |
@bcardarella @chriskrycho What is the standard around your application depending on third-party types?
|
They should normally be devDependencies.
|
👍 Excellent. Have been making some good progress on this and learning a lot about TypeScript in the process! |
@Bouke Can you share the type definition that you created with me? It might be helpful in a few places that I'm struggling right now. I'm specifically struggling to correctly convert the custom I can't find a way to extend Edit: By copying the import { Promise } from 'rsvp';
/**
* AJAX Promise
*
* Sub-class of RSVP Promise that passes the XHR property on to the
* child promise
*
* @extends RSVP.Promise
* @private
*/
export default class AJAXPromise<T> extends Promise<T> {
xhr?: XMLHttpRequest;
/**
* Overriding `.then` to add XHR to child promise
*
* @public
* @return {AJAXPromise} child promise
*/
then<TResult1 = T, TResult2 = never>(
onFulfilled?:
| ((value: T) => TResult1 | PromiseLike<TResult1>)
| undefined
| null,
onRejected?:
| ((reason: any) => TResult2 | PromiseLike<TResult2>)
| undefined
| null,
label?: string
): AJAXPromise<TResult1 | TResult2> {
const child = super.then(onFulfilled, onRejected, label);
(child as AJAXPromise<TResult1 | TResult2>).xhr = this.xhr;
return child;
}
} But this seems way more verbose than it should need to be... |
Just for information about the progress here, I've been working on the TypeScript conversion and #355 at the same time. I want to make sure that the FastBoot test is in place first, since I need to ensure that moving to TypeScript doesn't break anything and we have never had any real test coverage around the FastBoot support. |
Discovered an RSVP typings bug in the process 🙃 DefinitelyTyped/DefinitelyTyped#26640 |
Rather than continuing here, maybe I can ask some questions in #356 to get clarification on the "right way" to do certain things. An updated version of the |
Hello! I use your addon and really appreciate it. I'm also participating in this quest issue to add TypeScript support throughout the Ember.js ecosystem. (This will benefit to anyone who uses your addon, not just TypeScript users!) Are you interested in either converting the addon to use TypeScript itself, or in adding type definitions? I already have worked out most of the type definitions in my own project, which I could provide through DefinitelyTyped instead. Thanks!
The text was updated successfully, but these errors were encountered: