From a94ee28b625d6e7dbda7313f89b0e331735fe025 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 20 Mar 2020 11:53:58 -0700 Subject: [PATCH] d3-selection: Disable tslint error on TS 3.9 (#43269) DOM updates in 3.9 mean that Typescript now knows that `HTMLBodyElement.ownerDocument` can't actually be null. Previously, a non-null assertion was needed. Because the tests have to compile on 3.9 AND older versions, I just disabled the rule. --- types/d3-selection/d3-selection-tests.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/d3-selection/d3-selection-tests.ts b/types/d3-selection/d3-selection-tests.ts index 738c1bc2b7..318243dcfc 100644 --- a/types/d3-selection/d3-selection-tests.ts +++ b/types/d3-selection/d3-selection-tests.ts @@ -836,16 +836,19 @@ newDiv = body.append(function(d, i, g) { const index: number = i; const group: HTMLBodyElement[] | d3Selection.ArrayLike = g; console.log('Body element foo property: ', d.foo); // data of type BodyDatum + // tslint:disable-next-line:no-unnecessary-type-assertion return this.ownerDocument!.createElement('div'); // this-type HTMLBodyElement }); // $ExpectError newDiv = body.append(function(d) { + // tslint:disable-next-line:no-unnecessary-type-assertion return this.ownerDocument!.createElement('a'); // fails, HTMLDivElement expected by type parameter, HTMLAnchorElement returned }); // $ExpectError newDiv = body.append(function(d) { + // tslint:disable-next-line:no-unnecessary-type-assertion return this.ownerDocument!.createElement('a'); // fails, HTMLDivElement expected by inference, HTMLAnchorElement returned }); @@ -870,6 +873,7 @@ const typeValueFunction = function( i: number, g: HTMLBodyElement[] | d3Selection.ArrayLike ) { + // tslint:disable-next-line:no-unnecessary-type-assertion return this.ownerDocument!.createElement('p'); // this-type HTMLParagraphElement };