diff --git a/package.json b/package.json index e58b1028..67c8f175 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ "@angular/compiler-cli": "~11.0.2", "@angular/material": "~11.0.0", "@types/jasmine": "~3.6.0", - "@types/jasminewd2": "~2.0.3", "@types/lodash-es": "^4.17.3", "@types/node": "^12.11.1", "@types/prettier": "^2.0.1", diff --git a/projects/ng-core/src/lib/directive-superclass.spec.ts b/projects/ng-core/src/lib/directive-superclass.spec.ts index a1c6058a..f3708c74 100644 --- a/projects/ng-core/src/lib/directive-superclass.spec.ts +++ b/projects/ng-core/src/lib/directive-superclass.spec.ts @@ -4,11 +4,17 @@ import { Inject, Injector, Input, + Pipe, + PipeTransform, } from '@angular/core'; import { ComponentFixtureAutoDetect } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { ComponentContext, expectSingleCallAndReset } from '@s-libs/ng-dev'; -import { BehaviorSubject, combineLatest, Observable } from 'rxjs'; +import { + AngularContext, + ComponentContext, + expectSingleCallAndReset, +} from '@s-libs/ng-dev'; +import { BehaviorSubject, combineLatest, noop, Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { click, find, findButton } from '../test-helpers'; import { DirectiveSuperclass } from './directive-superclass'; @@ -115,6 +121,18 @@ describe('DirectiveSuperclass', () => { ///////// + it('can be used as the superclass to a pipe (production bug)', () => { + @Pipe({ name: 'not' }) + class NotPipe extends DirectiveSuperclass implements PipeTransform { + transform(value: any): boolean { + return !value; + } + } + expect(() => { + new AngularContext({ declarations: [NotPipe] }).run(noop); + }).not.toThrowError(); + }); + describe('.inputChanges$', () => { it('emits the keys that change', () => { ctx.run(() => { diff --git a/projects/ng-core/src/lib/directive-superclass.ts b/projects/ng-core/src/lib/directive-superclass.ts index 7ecb0fe6..52aefbbe 100644 --- a/projects/ng-core/src/lib/directive-superclass.ts +++ b/projects/ng-core/src/lib/directive-superclass.ts @@ -1,5 +1,6 @@ import { ChangeDetectorRef, + Directive, Injector, OnChanges, SimpleChanges, @@ -45,6 +46,9 @@ import { InjectableSuperclass } from './injectable-superclass'; * } * ``` */ +// maybe this won't need the fake selector after https://github.com/angular/angular/issues/36427 +@Directive({ selector: '[sDirectiveSuperclass]' }) +// tslint:disable-next-line:directive-class-suffix export abstract class DirectiveSuperclass extends InjectableSuperclass implements OnChanges { diff --git a/projects/ng-core/src/lib/injectable-superclass.ts b/projects/ng-core/src/lib/injectable-superclass.ts index 6b2511dd..3b5ac0dc 100644 --- a/projects/ng-core/src/lib/injectable-superclass.ts +++ b/projects/ng-core/src/lib/injectable-superclass.ts @@ -1,6 +1,6 @@ import { OnDestroy } from '@angular/core'; -import { Observable, Subject } from 'rxjs'; import { SubscriptionManager } from '@s-libs/rxjs-core'; +import { Observable, Subject } from 'rxjs'; /** * Use as the superclass for anything managed by angular's dependency injection for care-free use of `subscribeTo()`. It simply calls `unsubscribe()` during `ngOnDestroy()`. If you override `ngOnDestroy()` in your subclass, be sure to invoke the super implementation. diff --git a/projects/ng-core/src/typing-tests/tsconfig.json b/projects/ng-core/src/typing-tests/tsconfig.json index 3813d16a..b825ccb3 100644 --- a/projects/ng-core/src/typing-tests/tsconfig.json +++ b/projects/ng-core/src/typing-tests/tsconfig.json @@ -10,6 +10,7 @@ "target": "es2015", "baseUrl": "../lib", + "experimentalDecorators": true, "paths": { "@s-libs/micro-dash": ["../../../../dist/micro-dash"], "@s-libs/rxjs-core": ["../../../../dist/rxjs-core"] diff --git a/yarn.lock b/yarn.lock index 30b53cd0..4aaa7ca9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1339,18 +1339,11 @@ "@types/minimatch" "*" "@types/node" "*" -"@types/jasmine@*", "@types/jasmine@~3.6.0": +"@types/jasmine@~3.6.0": version "3.6.2" resolved "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.6.2.tgz#02f64450016f7de70f145d698be311136d7c6374" integrity sha512-AzfesNFLvOs6Q1mHzIsVJXSeUnqVh4ZHG8ngygKJfbkcSLwzrBVm/LKa+mR8KrOfnWtUL47112gde1MC0IXqpQ== -"@types/jasminewd2@~2.0.3": - version "2.0.8" - resolved "https://registry.npmjs.org/@types/jasminewd2/-/jasminewd2-2.0.8.tgz#67afe5098d5ef2386073a7b7384b69a840dfe93b" - integrity sha512-d9p31r7Nxk0ZH0U39PTH0hiDlJ+qNVGjlt1ucOoTUptxb2v+Y5VMnsxfwN+i3hK4yQnqBi3FMmoMFcd1JHDxdg== - dependencies: - "@types/jasmine" "*" - "@types/json-schema@^7.0.3", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.6": version "7.0.6" resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0"