Skip to content

Commit

Permalink
Merge pull request #20288 from emberjs/stabilize-owner-types
Browse files Browse the repository at this point in the history
[FEATURE] Stable types for `@ember/owner`
  • Loading branch information
chriskrycho authored Nov 30, 2022
2 parents cc92bc9 + d580037 commit d7b3f9d
Show file tree
Hide file tree
Showing 115 changed files with 339 additions and 809 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ dist/
tmp/
smoke-tests/
types/
type-tests/preview
type-tests/
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ jobs:
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
- name: Check types
run: yarn type-check
- name: build stable type definitions
run: yarn build:types
- name: Check published types
run: yarn type-check:types

types-range:
name: Type Checking (other supported versions)
Expand All @@ -61,10 +63,12 @@ jobs:
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile --non-interactive
- name: build stable type definitions
run: yarn build:types
- name: install TS@${{matrix.ts-version}}
run: yarn add -D typescript@${{ matrix.ts-version }}
- name: Check types with TS@${{matrix.ts-version}}
run: yarn type-check
- name: Check published types with TS@${{matrix.ts-version}}
run: yarn type-check:types

basic-test:
name: Debug and Prebuilt (All Tests by Package + Canary Features)
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
"url": "git+https://github.com/emberjs/ember.js.git"
},
"scripts": {
"build": "ember build --environment production",
"build:js": "ember build --environment production",
"build:types": "node types/publish.mjs",
"build": "npm-run-all build:*",
"docs": "ember ember-cli-yuidoc",
"types": "node types/publish.mjs",
"link:glimmer": "node bin/yarn-link-glimmer.js",
"start": "ember serve",
"lint": "npm-run-all --continue-on-error --aggregate-output --parallel \"lint:!(fix)\"",
Expand All @@ -49,8 +50,8 @@
"test:blueprints": "yarn test:blueprints:js && yarn test:blueprints:ts",
"test:node": "qunit tests/node/**/*-test.js",
"test:browserstack": "node bin/run-browserstack-tests.js",
"type-check:stable": "tsc --noEmit",
"type-check:preview": "tsc --noEmit --project type-tests/preview",
"type-check:internals": "tsc --noEmit",
"type-check:types": "tsc --noEmit --project type-tests",
"type-check": "npm-run-all type-check:*"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/@ember/owner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// We need to provide a narrower public interface to `getOwner` so that we only
// expose the `Owner` type, *not* our richer `InternalOwner` type and its
// various bits of private API.
import Owner, { getOwner as internalGetOwner } from '../-internals/owner';
import Owner, { getOwner as internalGetOwner } from '@ember/-internals/owner';

// NOTE: this documentation appears here instead of at the definition site so
// it can appear correctly in both API docs and for TS, while providing a richer
Expand Down Expand Up @@ -99,4 +99,4 @@ export {
KnownForTypeResult,
Resolver,
DIRegistry,
} from '../-internals/owner';
} from '@ember/-internals/owner';
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import Owner from '@ember/owner';
import ApplicationInstance from '@ember/application/instance';
import Service from '@ember/service';
import { expectTypeOf } from 'expect-type';
import { getOwner as getOwnerProper, setOwner as setOwnerProper } from '@ember/owner';

expectTypeOf(getOwner).toEqualTypeOf(getOwnerProper);
expectTypeOf(setOwner).toEqualTypeOf(setOwnerProper);

expectTypeOf(getOwner({})).toEqualTypeOf<Owner | undefined>();

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ import Owner, {
} from '@ember/owner';
import Component from '@glimmer/component';
import { expectTypeOf } from 'expect-type';
import {
getOwner as getOwnerApplication,
setOwner as setOwnerApplication,
} from '@ember/application';

expectTypeOf(getOwnerApplication).toEqualTypeOf(getOwner);
expectTypeOf(setOwnerApplication).toEqualTypeOf(setOwner);

// Just a class we can construct in the Factory and FactoryManager tests
declare class ConstructThis {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions type-tests/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This is equivalent to the import we have end users write.
import '../types/stable';
import '../types/preview';
1 change: 0 additions & 1 deletion type-tests/preview/index.d.ts

This file was deleted.

File renamed without changes.
3 changes: 0 additions & 3 deletions types/preview/@ember/application/tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions types/preview/@ember/array/tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions types/preview/@ember/component/tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions types/preview/@ember/controller/tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions types/preview/@ember/debug/tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions types/preview/@ember/destroyable/tsconfig.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module '@ember/engine/-private/container-proxy-mixin' {
import { ContainerProxy } from '@ember/owner';
import { ContainerProxy } from '@ember/-internals/owner';
import Mixin from '@ember/object/mixin';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module '@ember/engine/-private/registry-proxy-mixin' {
import { RegistryProxy } from '@ember/owner';
import { RegistryProxy } from '@ember/-internals/owner';
import Mixin from '@ember/object/mixin';

/**
Expand Down
3 changes: 0 additions & 3 deletions types/preview/@ember/engine/tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions types/preview/@ember/error/tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions types/preview/@ember/helper/tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions types/preview/@ember/modifier/tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions types/preview/@ember/object/tsconfig.json

This file was deleted.

Loading

0 comments on commit d7b3f9d

Please sign in to comment.