This reverts commit 1b4eaea6d4
.
PR Close #33299
This commit is contained in:
@ -406,77 +406,6 @@ export declare class CommonModule {
|
||||
expect(diags[1].length).toEqual(15);
|
||||
});
|
||||
|
||||
describe('input coercion', () => {
|
||||
beforeEach(() => {
|
||||
env.tsconfig({
|
||||
'fullTemplateTypeCheck': true,
|
||||
});
|
||||
env.write('node_modules/@angular/material/index.d.ts', `
|
||||
import * as i0 from '@angular/core';
|
||||
|
||||
export declare class MatInput {
|
||||
value: string;
|
||||
static ɵdir: i0.ɵɵDirectiveDefWithMeta<MatInput, '[matInput]', never, {'value': 'value'}, {}, never>;
|
||||
static ngCoerceInput_value(v: string|number): string;
|
||||
}
|
||||
|
||||
export declare class MatInputModule {
|
||||
static ɵmod: i0.ɵɵNgModuleDefWithMeta<MatInputModule, [typeof MatInput], never, [typeof MatInput]>;
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
it('should coerce an input using a coercion function if provided', () => {
|
||||
env.write('test.ts', `
|
||||
import {Component, NgModule} from '@angular/core';
|
||||
import {MatInputModule} from '@angular/material';
|
||||
|
||||
@Component({
|
||||
selector: 'blah',
|
||||
template: '<input matInput [value]="someNumber">',
|
||||
})
|
||||
export class FooCmp {
|
||||
someNumber = 3;
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [FooCmp],
|
||||
imports: [MatInputModule],
|
||||
})
|
||||
export class FooModule {}
|
||||
`);
|
||||
const diags = env.driveDiagnostics();
|
||||
expect(diags.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should give an error if the binding expression type is not accepted by the coercion function',
|
||||
() => {
|
||||
env.write('test.ts', `
|
||||
import {Component, NgModule} from '@angular/core';
|
||||
import {MatInputModule} from '@angular/material';
|
||||
|
||||
@Component({
|
||||
selector: 'blah',
|
||||
template: '<input matInput [value]="invalidType">',
|
||||
})
|
||||
export class FooCmp {
|
||||
invalidType = true;
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [FooCmp],
|
||||
imports: [MatInputModule],
|
||||
})
|
||||
export class FooModule {}
|
||||
`);
|
||||
const diags = env.driveDiagnostics();
|
||||
expect(diags.length).toBe(1);
|
||||
expect(diags[0].messageText)
|
||||
.toBe(
|
||||
`Argument of type 'boolean' is not assignable to parameter of type 'string | number'.`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('legacy schema checking with the DOM schema', () => {
|
||||
beforeEach(
|
||||
() => { env.tsconfig({ivyTemplateTypeCheck: true, fullTemplateTypeCheck: false}); });
|
||||
|
Reference in New Issue
Block a user