-
Notifications
You must be signed in to change notification settings - Fork 3
Types #17
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
Draft
daogrady
wants to merge
23
commits into
main
Choose a base branch
from
feat/types
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+622
−56
Draft
Types #17
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
0c00c93
First few types
daogrady 2c19746
Reuse Axios types
daogrady 6b129cf
Formatting
daogrady 9112ec4
More types
daogrady 64651b9
Merge branch 'main' into feat/types
daogrady 9aea8a8
Restore types
daogrady cec36d4
More types
daogrady 3099e43
Add globals
daogrady a6992c4
More types
daogrady d4727ef
Types
daogrady e064709
Types
daogrady 61f782e
Types
daogrady d780811
Types
daogrady 99a219d
Types
daogrady 1af46bf
Types
daogrady 31d21e6
Types
daogrady 48d97dc
Types
daogrady 96250b0
Types
daogrady 64f7214
Types
daogrady c977026
Types
daogrady 365fd8e
Types
daogrady f4855ec
Types
daogrady 3553c93
Types
daogrady 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
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 |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| const { inspect } = require('node:util') | ||
|
|
||
| /** | ||
| * @param {{status: any, body: any}} x | ||
| */ | ||
| const format = x => inspect( | ||
| is.error(x) ? x.message | ||
| : typeof x === 'object' && 'status' in x && 'body' in x ? { status: x.status, body: x.body } | ||
|
|
@@ -8,22 +12,39 @@ const format = x => inspect( | |
| ) | ||
|
|
||
| const expect = module.exports = actual => { | ||
| const chainable = function (x) { return this.call(x) }; delete chainable.length | ||
|
Author
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. |
||
| const chainable = function (x) { | ||
| return this.call(x) | ||
| } | ||
| return Object.setPrototypeOf(chainable, new Assertion(actual)) | ||
| } | ||
|
|
||
| /** | ||
| * @template T | ||
| * @typedef {(x: any) => x is T} Is */ | ||
|
|
||
| const is = new class { | ||
| Array = Array.isArray | ||
| /** @type {Is<Error>} */ | ||
| Error = x => x instanceof Error || x?.stack && x.message | ||
| /** @type {Is<Symbol>} */ | ||
| Symbol = x => typeof x === 'symbol' | ||
| /** @type {Is<Object>} */ | ||
| Object = x => typeof x === 'object' // && x && !is.array(x) | ||
| /** @type {Is<String>} */ | ||
| String = x => typeof x === 'string' || x instanceof String | ||
| /** @type {Is<Number>} */ | ||
| Number = x => typeof x === 'number' || x instanceof Number | ||
| /** @type {Is<Boolean>} */ | ||
| Boolean = x => typeof x === 'boolean' || x instanceof Boolean | ||
| /** @type {Is<Promise<unknown>>} */ | ||
| Promise = x => x instanceof Promise | ||
| /** @type {Is<RegExp>} */ | ||
| RegExp = x => x instanceof RegExp | ||
| /** @type {Is<Date>} */ | ||
| Date = x => x instanceof Date | ||
| /** @type {Is<Set<unknown>>} */ | ||
| Set = x => x instanceof Set | ||
| /** @type {Is<Map<unknown, unknown>>} */ | ||
| Map = x => x instanceof Map | ||
| array = this.Array | ||
| error = this.Error | ||
|
|
||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,25 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "strict": true, | ||
| "noImplicitAny": true, | ||
| "strictFunctionTypes": true, | ||
| "strictPropertyInitialization": true, | ||
| "strictBindCallApply": true, | ||
| "skipLibCheck": true, | ||
| "noImplicitThis": true, | ||
| "noImplicitReturns": true, | ||
| "alwaysStrict": true, | ||
| "esModuleInterop": true, | ||
| "checkJs": true, | ||
| "allowJs": true, | ||
| "declaration": true, | ||
| "target": "ES2016", | ||
| "module": "ESNext", | ||
| "moduleResolution": "node", | ||
| "outDir": "dist" | ||
| }, | ||
| "include": [ | ||
| "./lib/**/*.js" | ||
| ], | ||
| "verbose": true | ||
| } |
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.
Rewrite
to my understanding, this
super.… = …technique was used to have a truly private variable. I replaced them with actual private variables.