Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Stable types for @ember/owner #20288

Merged
merged 7 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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.
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