Skip to content

Commit

Permalink
WIP: composite projects in TS
Browse files Browse the repository at this point in the history
We won't be able to land this till we solve #20203, but it will be awesome
for preventing regressions once we *do*.
  • Loading branch information
chriskrycho committed Dec 6, 2022
1 parent ee51d79 commit 29008a6
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 37 deletions.
4 changes: 2 additions & 2 deletions packages/@ember/-internals/owner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export interface DIRegistry extends Record<string, Record<string, unknown>> {}
type ResolveFactoryManager<
Type extends string,
Name extends string
> = DIRegistry[Type][Name] extends object
? FactoryManager<DIRegistry[Type][Name]>
> = DIRegistry[Type][Name] extends infer RegistryEntry extends object
? FactoryManager<RegistryEntry>
: FactoryManager<object> | undefined;

/**
Expand Down
13 changes: 13 additions & 0 deletions packages/@ember/-internals/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../../tsconfig/compiler-options.json",
"compilerOptions": {
"composite": true
},
"include": [
"**/*"
],
"exclude": [
"**/tests",
"**/type-tests"
]
}
1 change: 1 addition & 0 deletions packages/@ember/-internals/tsconfig.tsbuildinfo

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/@ember/debug/container-debug-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { classify, dasherize } from '@ember/string';
import EmberObject from '@ember/object';
import { typeOf } from '@ember/utils';
import type { InternalOwner } from '@ember/-internals/owner';
import type Owner from '@ember/-internals/owner';
import { getOwner } from '@ember/-internals/owner';
import type { Resolver } from '@ember/owner';
import Namespace from '@ember/application/namespace';
Expand Down Expand Up @@ -45,10 +45,10 @@ import Namespace from '@ember/application/namespace';
@public
*/
export default class ContainerDebugAdapter extends EmberObject {
constructor(owner: InternalOwner) {
constructor(owner: Owner) {
super(owner);

this.resolver = getOwner(this)!.lookup('resolver-for-debugging:main') as Resolver;
this.resolver = owner.lookup('resolver-for-debugging:main') as Resolver;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/@ember/debug/data-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { InternalOwner } from '@ember/-internals/owner';
import { getOwner } from '@ember/-internals/owner';
import type Owner from '@ember/owner';
import { getOwner } from '@ember/owner';
import { _backburner, next } from '@ember/runloop';
import { get } from '@ember/object';
import { dasherize } from '@ember/string';
Expand Down Expand Up @@ -219,7 +219,7 @@ export default class DataAdapter<T> extends EmberObject {
// TODO: Revisit this
declare containerDebugAdapter: ContainerDebugAdapter;

constructor(owner: InternalOwner) {
constructor(owner: Owner) {
super(owner);
this.containerDebugAdapter = getOwner(this)!.lookup(
'container-debug-adapter:main'
Expand Down
12 changes: 12 additions & 0 deletions packages/@ember/debug/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../../tsconfig/compiler-options.json",
"compilerOptions": {
"composite": true
},
"include": ["**/*"],
"exclude": ["**/type-tests/*", "**/tests/*"],
"references": [
{ "path": "../-internals" }
{ "path": "../error" }
]
}
8 changes: 8 additions & 0 deletions packages/@ember/error/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig/compiler-options.json",
"compilerOptions": {
"composite": true
},
"include": ["**/*"],
"exclude": ["**/type-tests/*", "**/tests/*"]
}
10 changes: 10 additions & 0 deletions packages/@ember/owner/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig/compiler-options.json",
"compilerOptions": {
"composite": true
},
"files": ["index.ts"],
"references": [
{ "path": "../-internals" }
]
}
11 changes: 11 additions & 0 deletions packages/ember/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig/publish-types.json",
"compilerOptions": {
"composite": true
},
"files": [
"index.ts",
"version.d.ts"
],
"references": []
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./tsconfig/compiler-options.json",
"compilerOptions": {
"outDir": "dist",
"noEmit": true
"noEmit": true,
},
"include": ["packages/**/*.ts"],
"exclude": ["dist", "node_modules", "tmp", "types"]
Expand Down
13 changes: 13 additions & 0 deletions tsconfig/compiler-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@
"baseUrl": "../packages",
"rootDir": "../packages",

"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
// It'd be really nice to be able to supply sourcemaps, and at some point we
// will be able to by using e.g. rollup-plugin-ts once we solve other issues
// blocking that in our publishing pipeline by way of circular and repeated
// dependencies in the graph, but at the moment we are using `magic-string`
// to post-process these to add `declare module` declarations (see the
// `types/publish.mjs` script or details), and that doesn't support updating
// *existing* source maps, unfortunately.
"declarationMap": false,
"declarationDir": "../types/stable",

// Environment Configuration
"experimentalDecorators": true,
"moduleResolution": "node",
Expand Down
28 changes: 1 addition & 27 deletions tsconfig/publish-types.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./compiler-options.json",
"compilerOptions": {
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
// It'd be really nice to be able to supply sourcemaps, and at some point we
// will be able to by using e.g. rollup-plugin-ts once we solve other issues
// blocking that in our publishing pipeline by way of circular and repeated
// dependencies in the graph, but at the moment we are using `magic-string`
// to post-process these to add `declare module` declarations (see the
// `types/publish.mjs` script or details), and that doesn't support updating
// *existing* source maps, unfortunately.
"declarationMap": false,
"declarationDir": "../types/stable"
},
"include": [
// Note: these will also pull on all their transitive dependencies, so we
// will end up publishing the (private!) types for packages not named here
// until we update the actual internals to avoid referencing them!
"../packages/@ember/**/*",
"../packages/ember/**/*",
"../packages/@glimmer/**/*"
],
"exclude": [
"../**/type-tests",
"../**/tests",
"../**/internal-test-helpers"
]
"references": [{ "path": "../packages/@ember/owner" }]
}
2 changes: 1 addition & 1 deletion types/publish.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ async function main() {
fs.rmSync(TYPES_DIR, { recursive: true, force: true });
fs.mkdirSync(TYPES_DIR, { recursive: true });

spawnSync('yarn', ['tsc', '--project', 'tsconfig/publish-types.json']);
spawnSync('yarn', ['tsc', '--build', 'tsconfig/publish-types.json']);

// This is rooted in the `TYPES_DIR` so that the result is just the names of
// the modules, as generated directly from the tsconfig above.
Expand Down

0 comments on commit 29008a6

Please sign in to comment.