added TypeScript definitions for "html" and "svg"#40
Open
fogzot wants to merge 1 commit intoobservablehq:mainfrom
Open
added TypeScript definitions for "html" and "svg"#40fogzot wants to merge 1 commit intoobservablehq:mainfrom
fogzot wants to merge 1 commit intoobservablehq:mainfrom
Conversation
lionel-rowe
reviewed
Feb 1, 2023
Comment on lines
+2
to
+13
| /** Renders the specified markup as an element, text node, or null as appropriate. */ | ||
| const html: { | ||
| <T extends HTMLElement | Text | null>(...args: any[]): T; | ||
| /** Renders the specified markup as a document fragment. */ | ||
| fragment(...args: any[]): DocumentFragment; | ||
| }; | ||
| /** Renders the specified markup as an SVG element, text node, or null as appropriate. */ | ||
| const svg: { | ||
| <T extends SVGElement | Text | null>(...args: any[]): T; | ||
| /** Renders the specified markup as a document fragment. */ | ||
| fragment(...args: any[]): DocumentFragment; | ||
| }; |
There was a problem hiding this comment.
Slightly improved typings to have the proper tagged template string params (as per typings for String.raw):
Suggested change
| /** Renders the specified markup as an element, text node, or null as appropriate. */ | |
| const html: { | |
| <T extends HTMLElement | Text | null>(...args: any[]): T; | |
| /** Renders the specified markup as a document fragment. */ | |
| fragment(...args: any[]): DocumentFragment; | |
| }; | |
| /** Renders the specified markup as an SVG element, text node, or null as appropriate. */ | |
| const svg: { | |
| <T extends SVGElement | Text | null>(...args: any[]): T; | |
| /** Renders the specified markup as a document fragment. */ | |
| fragment(...args: any[]): DocumentFragment; | |
| }; | |
| type TaggedTemplateParams = [ | |
| template: { raw: readonly string[] | ArrayLike<string> }, | |
| ...substitutions: any[], | |
| ]; | |
| /** Renders the specified markup as an HTML element, text node, or null as appropriate. */ | |
| const html: { | |
| <T extends HTMLElement | Text | null>(...args: TaggedTemplateParams): T; | |
| /** Renders the specified markup as a document fragment. */ | |
| fragment(...args: TaggedTemplateParams): DocumentFragment; | |
| }; | |
| /** Renders the specified markup as an SVG element, text node, or null as appropriate. */ | |
| const svg: { | |
| <T extends SVGElement | Text | null>(...args: TaggedTemplateParams): T; | |
| /** Renders the specified markup as a document fragment. */ | |
| fragment(...args: TaggedTemplateParams): DocumentFragment; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The type definitions added by this commit are pretty basic, but enough to import and use the package from TypeScript.