-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript definition changes and explaining Sinuous internals #114
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3f07873
More accurate types for the hyperscript reviver and the internal API
nettyso 887b348
Merge type accuracy changes that were in master
nettyso 9d1034e
Using a real boolean since Terser is really good
nettyso 8964790
Missed an ESLint comment
nettyso d5f4f7e
Whitespace indentation
nettyso 2454ac5
Add `api.hs` typing
nettyso 133bed6
Again, more accurate types
nettyso 27cc7fd
Node | Frag
nettyso be56557
Lessons learned building lifecycles into Sinuous
nettyso File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,31 +11,35 @@ declare namespace _h { | |
Record<string, unknown> | ||
| null, | ||
...children: ElementChildren[] | ||
): HTMLElement; | ||
): HTMLElement | SVGElement; | ||
function h( | ||
type: FunctionComponent, | ||
props: | ||
| (JSXInternal.HTMLAttributes | JSXInternal.SVGAttributes) & | ||
Record<string, unknown> | ||
| null, | ||
...children: ElementChildren[] | ||
): HTMLElement; | ||
): HTMLElement | SVGElement | DocumentFragment; | ||
function h( | ||
children: ElementChildren[] | ||
tag: ElementChildren[] | [], | ||
...children: ElementChildren[] | ||
): DocumentFragment; | ||
namespace h { | ||
export import JSX = JSXInternal; | ||
} | ||
} | ||
|
||
type Frag = { _startMark: Text } | ||
type Value = Node | DocumentFragment | string | number | ||
|
||
export interface HyperscriptApi { | ||
// Hyperscript | ||
h: typeof _h.h; | ||
|
||
// Internal API | ||
insert<T>(el: Node, value: T, endMark?: Node, current?: T, startNode?: Node): T; | ||
insert<T>(el: Node, value: T, endMark?: Node, current?: T | Frag, startNode?: Node): T | Frag; | ||
property(el: Node, value: unknown, name: string, isAttr?: boolean, isCss?: boolean): void; | ||
add(parent: Node, value: Node | string, endMark?: Node): Node; | ||
add(parent: Node, value: Value | Value[], endMark?: Node): Node | Frag; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So... |
||
rm(parent: Node, startNode: Node, endMark: Node): void; | ||
|
||
// Required from an observable implmentation | ||
|
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We merged this file earlier in my ts-work branch but really I'm lying to people to say it's only HTMLElement in h/index.d.ts - It's true that later on in src/index.d.ts and jsx/index.d.ts the types are redefined to be more narrow, but until then it's good to define the reviver as generic for both HTML/SVG