-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20489 from emberjs/types/resolver-fix
[BUGFIX stable] Fix types for Resolver contract
- Loading branch information
Showing
11 changed files
with
71 additions
and
56 deletions.
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
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 |
---|---|---|
@@ -1,25 +1,8 @@ | ||
import { expectTypeOf } from 'expect-type'; | ||
import { Person } from './create'; | ||
|
||
// Let's see some *real* type-unsafety! These demonstrate that we just | ||
// absolutely lie about the runtime behavior for `.create()`. 😬 The result of | ||
// calling these with `firstName: 99` is to *change the type* of the resulting | ||
// object from `Person` to `Person` with `firstName: number`. While we might | ||
// *like* to prevent that call and make sure that `firstName` matches the type | ||
// we cannot reasonably do so. | ||
|
||
expectTypeOf(Person.create({ firstName: 99 })).toEqualTypeOf< | ||
Person & { | ||
firstName: number; | ||
} | ||
>(); | ||
expectTypeOf(Person.create({}, { firstName: 99 })).toEqualTypeOf< | ||
Person & { | ||
firstName: number; | ||
} | ||
>(); | ||
expectTypeOf(Person.create({}, {}, { firstName: 99 })).toEqualTypeOf< | ||
Person & { | ||
firstName: number; | ||
} | ||
>(); | ||
// @ts-expect-error | ||
Person.create({ firstName: 99 }); | ||
// @ts-expect-error | ||
Person.create({}, { firstName: 99 }); | ||
// @ts-expect-error | ||
Person.create({}, {}, { firstName: 99 }); |
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 |
---|---|---|
@@ -1,25 +1,8 @@ | ||
import { expectTypeOf } from 'expect-type'; | ||
import { Person } from './create'; | ||
|
||
// Let's see some *real* type-unsafety! These demonstrate that we just | ||
// absolutely lie about the runtime behavior for `.create()`. 😬 The result of | ||
// calling these with `firstName: 99` is to *change the type* of the resulting | ||
// object from `Person` to `Person` with `firstName: number`. While we might | ||
// *like* to prevent that call and make sure that `firstName` matches the type | ||
// we cannot reasonably do so. | ||
|
||
expectTypeOf(Person.create({ firstName: 99 })).toEqualTypeOf< | ||
Person & { | ||
firstName: number; | ||
} | ||
>(); | ||
expectTypeOf(Person.create({}, { firstName: 99 })).toEqualTypeOf< | ||
Person & { | ||
firstName: number; | ||
} | ||
>(); | ||
expectTypeOf(Person.create({}, {}, { firstName: 99 })).toEqualTypeOf< | ||
Person & { | ||
firstName: number; | ||
} | ||
>(); | ||
// @ts-expect-error | ||
Person.create({ firstName: 99 }); | ||
// @ts-expect-error | ||
Person.create({}, { firstName: 99 }); | ||
// @ts-expect-error | ||
Person.create({}, {}, { firstName: 99 }); |
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,12 @@ | ||
import Application from '@ember/application'; | ||
import Resolver from './ember-resolver-alike'; | ||
import loadInitializers from './ember-load-initializers-alike'; | ||
import config from './environment-alike'; | ||
|
||
export default class App extends Application { | ||
modulePrefix = config.modulePrefix; | ||
podModulePrefix = config.podModulePrefix; | ||
Resolver = Resolver; | ||
} | ||
|
||
loadInitializers(App, config.modulePrefix); |
10 changes: 10 additions & 0 deletions
10
type-tests/smoke/basic-app-alike/ember-load-initializers-alike.d.ts
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,10 @@ | ||
declare global { | ||
var requirejs: { | ||
_eak_seen: Object; | ||
}; | ||
} | ||
import Engine from '@ember/engine'; | ||
/** | ||
* Configure your application as it boots | ||
*/ | ||
export default function loadInitializers(app: typeof Engine, prefix: string): void; |
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,4 @@ | ||
import { Resolver as ResolverContract } from '@ember/owner'; | ||
import EmberObject from '@ember/object'; | ||
export default class Resolver extends EmberObject {} | ||
export default interface Resolver extends Required<ResolverContract> {} |
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,14 @@ | ||
/** | ||
* Type declarations for | ||
* import config from 'my-app/config/environment' | ||
*/ | ||
declare const config: { | ||
environment: string; | ||
modulePrefix: string; | ||
podModulePrefix: string; | ||
locationType: 'history' | 'hash' | 'none' | 'auto'; | ||
rootURL: string; | ||
APP: Record<string, unknown>; | ||
}; | ||
|
||
export default config; |