diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts index 89532451b3..de43996898 100755 --- a/types/ember/index.d.ts +++ b/types/ember/index.d.ts @@ -496,6 +496,10 @@ declare module 'ember' { * object when the boot process is complete. */ boot(): Promise; + /** + * Create an ApplicationInstance for this Application. + */ + buildInstance(options?: object): ApplicationInstance; } /** The `ApplicationInstance` encapsulates all of the stateful aspects of a @@ -1113,6 +1117,10 @@ declare module 'ember' { * Set this to provide an alternate class to `Ember.DefaultResolver` */ resolver: Resolver; + /** + * Create an EngineInstance for this Engine. + */ + buildInstance(options?: object): EngineInstance; } /** * The `EngineInstance` encapsulates all of the stateful aspects of a diff --git a/types/ember/test/application.ts b/types/ember/test/application.ts index d0fc2e9c44..fe4152c01a 100755 --- a/types/ember/test/application.ts +++ b/types/ember/test/application.ts @@ -33,3 +33,9 @@ let App2 = BaseApp.create({ mouseleave: null } }); + +let App3 = BaseApp.create(); + +let App3Instance1 = App3.buildInstance(); + +let App3Instance2 = App3.buildInstance({ foo: 'bar' }); diff --git a/types/ember/test/engine.ts b/types/ember/test/engine.ts new file mode 100755 index 0000000000..508bd3be4d --- /dev/null +++ b/types/ember/test/engine.ts @@ -0,0 +1,41 @@ +import Ember from 'ember'; +import { assertType } from "./lib/assert"; + +let BaseEngine = Ember.Engine.extend({ + modulePrefix: 'my-engine' +}); + +BaseEngine.initializer({ + name: 'my-initializer', + initialize(engine) { + engine.register('foo:bar', Ember.Object.extend({ foo: 'bar' })); + } +}); + +BaseEngine.instanceInitializer({ + name: 'my-instance-initializer', + initialize(engine) { + engine.lookup('foo:bar').get('foo'); + } +}); + +let Engine1 = BaseEngine.create({ + rootElement: '#engine-one', + customEvents: { + paste: 'paste' + } +}); + +let Engine2 = BaseEngine.create({ + rootElement: '#engine-two', + customEvents: { + mouseenter: null, + mouseleave: null + } +}); + +let Engine3 = BaseEngine.create(); + +let Engine3Instance1 = Engine3.buildInstance(); + +let Engine3Instance2 = Engine3.buildInstance({ foo: 'bar' }); diff --git a/types/ember/tsconfig.json b/types/ember/tsconfig.json index 4ff7e7bf07..29f20bcc44 100755 --- a/types/ember/tsconfig.json +++ b/types/ember/tsconfig.json @@ -24,6 +24,7 @@ "test/application.ts", "test/access-modifier.ts", "test/application-instance.ts", + "test/engine.ts", "test/engine-instance.ts", "test/ember-tests.ts", "test/error.ts",