-
-
Notifications
You must be signed in to change notification settings - Fork 3
Add types #7
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
Merged
Merged
Add types #7
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9964334
Add typings
Roang-zero1 665bdd2
Fix test is optional
Roang-zero1 b523a42
Add type tests
Roang-zero1 240ea86
Update index.d.ts
Roang-zero1 e981532
Update index.d.ts
Roang-zero1 e2cca83
Update tsconfig.json
Roang-zero1 0a40a43
Update index.d.ts
Roang-zero1 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// TypeScript Version: 3.5 | ||
|
||
import {Node, Parent} from 'unist' | ||
import {Test} from 'unist-util-is' | ||
|
||
export = findAllAfter | ||
/** | ||
* Unist utility to get all children of a parent after a node or index | ||
* | ||
* @param parent Parent to search in | ||
* @param index or Node to start from | ||
* @param test that Nodes must pass to be included | ||
* @returns Array of found Nodes | ||
*/ | ||
declare function findAllAfter<T extends Node>( | ||
parent: Parent, | ||
index: number | Node, | ||
test?: Test<T> | Array<Test<T>> | ||
): Node[] |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2015"], | ||
"strict": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"unist-util-find-all-after": ["index.d.ts"] | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "dtslint/dtslint.json", | ||
"rules": { | ||
"semicolon": false, | ||
"whitespace": false | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {Node, Parent} from 'unist' | ||
import findAllAfter = require('unist-util-find-all-after') | ||
|
||
const heading: Node = { | ||
type: 'heading', | ||
depth: 2, | ||
children: [] | ||
} | ||
|
||
const parent: Parent = { | ||
type: 'root', | ||
children: [heading] | ||
} | ||
|
||
/*=== missing params ===*/ | ||
// $ExpectError | ||
findAllAfter() | ||
// $ExpectError | ||
findAllAfter(parent) | ||
|
||
/*=== find by index/node ===*/ | ||
findAllAfter(parent, 1) | ||
findAllAfter(parent, heading) | ||
// $ExpectError | ||
findAllAfter(parent, false) | ||
|
||
/*=== find with test ===*/ | ||
// $ExpectError | ||
findAllAfter(parent, 1, false) | ||
findAllAfter(parent, 1, 'paragraph') | ||
|
||
/*=== invalid return ===*/ | ||
// $ExpectError | ||
const returnIsString: string = findAllAfter(parent, 1) | ||
|
||
/*=== valid return ===*/ | ||
const nodes: Node[] = findAllAfter(parent, 1) |
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.
Uh oh!
There was an error while loading. Please reload this page.