Skip to content

Commit

Permalink
fix: explictly declare types for mixin base classes (#12876)
Browse files Browse the repository at this point in the history
As of TypeScript 2.9, tsc will inline imports for inferred types with
the `import("...")` syntax. However, this inlining happens *after*
`paths` are resolved. This means that in places where we import from
`@angular/material/core` in source end up having relative paths (e.g.
`../core/common-behaviors/index`) in the generated d.ts files. These
relative import paths become incorrect when moved into our package
structure, breaking downstream apps.
  • Loading branch information
jelbourn authored Aug 29, 2018
1 parent 73d54a4 commit 515912b
Show file tree
Hide file tree
Showing 45 changed files with 392 additions and 243 deletions.
116 changes: 67 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"version": "6.4.6",
"requiredAngularVersion": ">=6.0.0 <7.0.0",
"dependencies": {
"@angular/animations": "^6.1.0",
"@angular/common": "^6.1.0",
"@angular/compiler": "^6.1.0",
"@angular/core": "^6.1.0",
"@angular/elements": "^6.1.0",
"@angular/forms": "^6.1.0",
"@angular/platform-browser": "^6.1.0",
"@angular/animations": "7.0.0-beta.3",
"@angular/common": "7.0.0-beta.3",
"@angular/compiler": "7.0.0-beta.3",
"@angular/core": "7.0.0-beta.3",
"@angular/elements": "7.0.0-beta.3",
"@angular/forms": "7.0.0-beta.3",
"@angular/platform-browser": "7.0.0-beta.3",
"@webcomponents/custom-elements": "^1.1.0",
"core-js": "^2.4.1",
"rxjs": "^6.2.0",
Expand All @@ -45,13 +45,13 @@
"devDependencies": {
"@angular-devkit/core": "^0.7.1",
"@angular-devkit/schematics": "^0.7.1",
"@angular/bazel": "^6.1.0",
"@angular/compiler-cli": "^6.1.0",
"@angular/http": "^6.1.0",
"@angular/platform-browser-dynamic": "^6.1.0",
"@angular/platform-server": "^6.1.0",
"@angular/router": "^6.1.0",
"@angular/upgrade": "^6.1.0",
"@angular/bazel": "7.0.0-beta.3",
"@angular/compiler-cli": "7.0.0-beta.3",
"@angular/http": "7.0.0-beta.3",
"@angular/platform-browser-dynamic": "7.0.0-beta.3",
"@angular/platform-server": "7.0.0-beta.3",
"@angular/router": "7.0.0-beta.3",
"@angular/upgrade": "7.0.0-beta.3",
"@bazel/ibazel": "0.3.1",
"@google-cloud/storage": "^1.1.1",
"@octokit/rest": "^15.9.4",
Expand Down
6 changes: 4 additions & 2 deletions src/cdk/table/can-stick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ export interface CanStick {
resetStickyChanged(): void;
}

/** @docs-private */
export type CanStickCtor = Constructor<CanStick>;

/**
* Mixin to provide a directive with a function that checks if the sticky input has been
* changed since the last time the function was called. Essentially adds a dirty-check to the
* sticky value.
* @docs-private
*/
export function mixinHasStickyInput<T extends Constructor<{}>>(base: T):
Constructor<CanStick> & T {
export function mixinHasStickyInput<T extends Constructor<{}>>(base: T): CanStickCtor & T {
return class extends base {
/** Whether sticky positioning should be applied. */
get sticky(): boolean { return this._sticky; }
Expand Down
8 changes: 5 additions & 3 deletions src/cdk/table/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ContentChild, Directive, ElementRef, Input, TemplateRef} from '@angular/core';
import {coerceBooleanProperty} from '@angular/cdk/coercion';
import {CanStick, mixinHasStickyInput} from './can-stick';
import {ContentChild, Directive, ElementRef, Input, TemplateRef} from '@angular/core';
import {CanStick, CanStickCtor, mixinHasStickyInput} from './can-stick';


/** Base interface for a cell definition. Captures a column's cell template definition. */
export interface CellDef {
Expand Down Expand Up @@ -45,7 +46,8 @@ export class CdkFooterCellDef implements CellDef {
// Boilerplate for applying mixins to CdkColumnDef.
/** @docs-private */
export class CdkColumnDefBase {}
export const _CdkColumnDefBase = mixinHasStickyInput(CdkColumnDefBase);
export const _CdkColumnDefBase: CanStickCtor & typeof CdkColumnDefBase =
mixinHasStickyInput(CdkColumnDefBase);

/**
* Column definition for the CDK table.
Expand Down
8 changes: 5 additions & 3 deletions src/cdk/table/row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import {
ViewContainerRef,
ViewEncapsulation,
} from '@angular/core';
import {CanStick, CanStickCtor, mixinHasStickyInput} from './can-stick';
import {CdkCellDef, CdkColumnDef} from './cell';
import {CanStick, mixinHasStickyInput} from './can-stick';

/**
* The row template that can be used by the mat-table. Should not be used outside of the
Expand Down Expand Up @@ -76,7 +76,8 @@ export abstract class BaseRowDef implements OnChanges {
// Boilerplate for applying mixins to CdkHeaderRowDef.
/** @docs-private */
export class CdkHeaderRowDefBase extends BaseRowDef {}
export const _CdkHeaderRowDefBase = mixinHasStickyInput(CdkHeaderRowDefBase);
export const _CdkHeaderRowDefBase: CanStickCtor & typeof CdkHeaderRowDefBase =
mixinHasStickyInput(CdkHeaderRowDefBase);

/**
* Header row definition for the CDK table.
Expand All @@ -101,7 +102,8 @@ export class CdkHeaderRowDef extends _CdkHeaderRowDefBase implements CanStick, O
// Boilerplate for applying mixins to CdkFooterRowDef.
/** @docs-private */
export class CdkFooterRowDefBase extends BaseRowDef {}
export const _CdkFooterRowDefBase = mixinHasStickyInput(CdkFooterRowDefBase);
export const _CdkFooterRowDefBase: CanStickCtor & typeof CdkFooterRowDefBase =
mixinHasStickyInput(CdkFooterRowDefBase);

/**
* Footer row definition for the CDK table.
Expand Down
Loading

0 comments on commit 515912b

Please sign in to comment.