diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index d3b64fd20..2db623fea 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -2990,6 +2990,9 @@ interface Attr extends Node { readonly specified: boolean; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/value) */ value: string; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): string; + set textContent(value: string | null); } declare var Attr: { @@ -6531,6 +6534,9 @@ interface CharacterData extends Node, ChildNode, NonDocumentTypeChildNode { replaceData(offset: number, count: number, data: string): void; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/substringData) */ substringData(offset: number, count: number): string; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): string; + set textContent(value: string | null); } declare var CharacterData: { @@ -8508,6 +8514,8 @@ interface Document extends Node, DocumentOrShadowRoot, FontFaceSource, GlobalEve * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/writeln) */ writeln(...text: string[]): void; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): null; addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; @@ -8529,6 +8537,9 @@ declare var Document: { interface DocumentFragment extends Node, NonElementParentNode, ParentNode { readonly ownerDocument: Document; getElementById(elementId: string): HTMLElement | null; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): string; + set textContent(value: string | null); } declare var DocumentFragment: { @@ -8602,6 +8613,8 @@ interface DocumentType extends Node, ChildNode { readonly publicId: string; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType/systemId) */ readonly systemId: string; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): null; } declare var DocumentType: { @@ -9035,6 +9048,9 @@ interface Element extends Node, ARIAMixin, Animatable, ChildNode, NonDocumentTyp * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/matches) */ webkitMatchesSelector(selectors: string): boolean; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): string; + set textContent(value: string | null); addEventListener(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; diff --git a/baselines/ts5.5/dom.generated.d.ts b/baselines/ts5.5/dom.generated.d.ts index 31829ff26..d877dcbdc 100644 --- a/baselines/ts5.5/dom.generated.d.ts +++ b/baselines/ts5.5/dom.generated.d.ts @@ -2990,6 +2990,9 @@ interface Attr extends Node { readonly specified: boolean; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/value) */ value: string; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): string; + set textContent(value: string | null); } declare var Attr: { @@ -6524,6 +6527,9 @@ interface CharacterData extends Node, ChildNode, NonDocumentTypeChildNode { replaceData(offset: number, count: number, data: string): void; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/substringData) */ substringData(offset: number, count: number): string; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): string; + set textContent(value: string | null); } declare var CharacterData: { @@ -8501,6 +8507,8 @@ interface Document extends Node, DocumentOrShadowRoot, FontFaceSource, GlobalEve * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/writeln) */ writeln(...text: string[]): void; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): null; addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; @@ -8522,6 +8530,9 @@ declare var Document: { interface DocumentFragment extends Node, NonElementParentNode, ParentNode { readonly ownerDocument: Document; getElementById(elementId: string): HTMLElement | null; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): string; + set textContent(value: string | null); } declare var DocumentFragment: { @@ -8595,6 +8606,8 @@ interface DocumentType extends Node, ChildNode { readonly publicId: string; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType/systemId) */ readonly systemId: string; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): null; } declare var DocumentType: { @@ -9026,6 +9039,9 @@ interface Element extends Node, ARIAMixin, Animatable, ChildNode, NonDocumentTyp * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/matches) */ webkitMatchesSelector(selectors: string): boolean; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): string; + set textContent(value: string | null); addEventListener(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; diff --git a/baselines/ts5.6/dom.generated.d.ts b/baselines/ts5.6/dom.generated.d.ts index 435ce4c60..9243a444a 100644 --- a/baselines/ts5.6/dom.generated.d.ts +++ b/baselines/ts5.6/dom.generated.d.ts @@ -2990,6 +2990,9 @@ interface Attr extends Node { readonly specified: boolean; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/value) */ value: string; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): string; + set textContent(value: string | null); } declare var Attr: { @@ -6531,6 +6534,9 @@ interface CharacterData extends Node, ChildNode, NonDocumentTypeChildNode { replaceData(offset: number, count: number, data: string): void; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/substringData) */ substringData(offset: number, count: number): string; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): string; + set textContent(value: string | null); } declare var CharacterData: { @@ -8508,6 +8514,8 @@ interface Document extends Node, DocumentOrShadowRoot, FontFaceSource, GlobalEve * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/writeln) */ writeln(...text: string[]): void; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): null; addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; @@ -8529,6 +8537,9 @@ declare var Document: { interface DocumentFragment extends Node, NonElementParentNode, ParentNode { readonly ownerDocument: Document; getElementById(elementId: string): HTMLElement | null; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): string; + set textContent(value: string | null); } declare var DocumentFragment: { @@ -8602,6 +8613,8 @@ interface DocumentType extends Node, ChildNode { readonly publicId: string; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType/systemId) */ readonly systemId: string; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): null; } declare var DocumentType: { @@ -9035,6 +9048,9 @@ interface Element extends Node, ARIAMixin, Animatable, ChildNode, NonDocumentTyp * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/matches) */ webkitMatchesSelector(selectors: string): boolean; + /** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) */ + get textContent(): string; + set textContent(value: string | null); addEventListener(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; diff --git a/inputfiles/addedTypes.jsonc b/inputfiles/addedTypes.jsonc index ff6e0bbe0..ddb79b34f 100644 --- a/inputfiles/addedTypes.jsonc +++ b/inputfiles/addedTypes.jsonc @@ -801,6 +801,13 @@ ] } } + }, + "textContent": { + "mdnUrl": "https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent", + "overrideSignatures": [ + "get textContent(): string", + "set textContent(value: string | null)" + ] } } }, @@ -1228,6 +1235,17 @@ }, "Attr": { "name": "Attr", + "methods": { + "method": { + "textContent": { + "mdnUrl": "https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent", + "overrideSignatures": [ + "get textContent(): string", + "set textContent(value: string | null)" + ] + } + } + }, "properties": { "property": { "ownerDocument": { @@ -1240,6 +1258,17 @@ }, "CharacterData": { "name": "CharacterData", + "methods": { + "method": { + "textContent": { + "mdnUrl": "https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent", + "overrideSignatures": [ + "get textContent(): string", + "set textContent(value: string | null)" + ] + } + } + }, "properties": { "property": { "ownerDocument": { @@ -1260,6 +1289,16 @@ "type": "Document" } } + }, + "methods": { + "method": { + "textContent": { + "mdnUrl": "https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent", + "overrideSignatures": [ + "get textContent(): null" + ] + } + } } }, "ProcessingInstruction": { diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index d87d431f5..f7332d04d 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -831,6 +831,12 @@ "overrideType": "NodeListOf" } } + }, + "textContent": { + "mdnUrl": "https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent", + "overrideSignatures": [ + "get textContent(): null" + ] } } }, @@ -897,6 +903,13 @@ "overrideSignatures": [ "getElementById(elementId: string): HTMLElement | null" ] + }, + "textContent": { + "mdnUrl": "https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent", + "overrideSignatures": [ + "get textContent(): string", + "set textContent(value: string | null)" + ] } } }, diff --git a/unittests/files/textContent.ts b/unittests/files/textContent.ts new file mode 100644 index 000000000..ad0ed1d79 --- /dev/null +++ b/unittests/files/textContent.ts @@ -0,0 +1,48 @@ +declare const assertType: () => ( + _x: T1, +) => StrictEqual extends true + ? () => void + : T1 extends T + ? { error: "Left side is not assignable to right side" } + : { error: "Right side is not assignable to left side" }; + +type StrictEqual = + (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 + ? true + : false; + +// string: +declare const element: Element; +assertType()(element.textContent)(); +element.textContent = null; + +declare const characterData: CharacterData; +assertType()(characterData.textContent)(); +characterData.textContent = null; + +declare const text: Text; +assertType()(text.textContent)(); +text.textContent = null; + +declare const comment: Comment; +assertType()(comment.textContent)(); +comment.textContent = null; + +declare const processingInstruction: ProcessingInstruction; +assertType()(processingInstruction.textContent)(); +processingInstruction.textContent = null; + +declare const documentFragment: DocumentFragment; +assertType()(documentFragment.textContent)(); + +declare const attr: Attr; +assertType()(attr.textContent)(); +attr.textContent = null; + +// null: +assertType()(document.textContent)(); + +declare const documentType: DocumentType; +assertType()(documentType.textContent)(); + +export {};