This repository has been archived by the owner on Jul 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Class-based approach for typed object model #11
Merged
dwickern
merged 5 commits into
typed-ember:new-object-model
from
dfreeman:new-object-model
Aug 27, 2017
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Ember from 'ember'; | ||
import { assertType } from './lib/assert'; | ||
|
||
const ExtendClass = Ember.Object.extend({ | ||
foo: 'hello' | ||
}); | ||
|
||
class ES6Class extends Ember.Object { | ||
bar: string; | ||
} | ||
|
||
let testObject = null; | ||
|
||
if (ExtendClass.detectInstance(testObject)) { | ||
assertType<string>(testObject.foo); | ||
} | ||
|
||
if (ES6Class.detectInstance(testObject)) { | ||
assertType<string>(testObject.bar); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Ember from 'ember'; | ||
import { assertType } from './lib/assert'; | ||
|
||
const ExtendClass = Ember.Object.extend({ | ||
foo: 'hello' | ||
}); | ||
|
||
class ES6Class extends Ember.Object { | ||
bar: string; | ||
} | ||
|
||
let TestClass = Ember.Object; | ||
|
||
if (ExtendClass.detect(TestClass)) { | ||
assertType<string>(TestClass.create().foo); | ||
} | ||
|
||
if (ES6Class.detect(TestClass)) { | ||
assertType<string>(TestClass.create().bar); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One side effect I can see is that arguments to method overrides are no longer inferred. For instance since we know the argument types to
setupController
we shouldn't have to specify them:After reading microsoft/TypeScript#6118 and the linked issues, typescript surprisingly doesn't support this! So rather than implementing it in our bespoke object model, I'd rather remove it and wait for an official solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I totally missed that that was happening before! (And didn't stop to reflect on why I'd unthinkingly made that change in this file). While it's pretty cool that that was working, I'd agree that sticking as close to the vanilla object model as possible will hopefully yield us the best results in the long run :)