-
Notifications
You must be signed in to change notification settings - Fork 906
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add types to
@solana/fast-stable-stringify
(#2502)
This thing returns a string always, unless you pass it `undefined` or a function.
- Loading branch information
1 parent
f396267
commit 5ed19c6
Showing
6 changed files
with
52 additions
and
12 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@solana/fast-stable-stringify": patch | ||
--- | ||
|
||
Added TypeScript types to `@solana/fast-stable-stringify` |
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
20 changes: 20 additions & 0 deletions
20
packages/fast-stable-stringify/src/__typetests__/index-typetest.ts
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import fastStableStringify from '../index'; | ||
|
||
fastStableStringify(undefined) satisfies undefined; | ||
fastStableStringify(function () {}) satisfies undefined; | ||
fastStableStringify(() => {}) satisfies undefined; | ||
fastStableStringify(class Foo {}) satisfies undefined; | ||
|
||
fastStableStringify({ UNDEFINED: undefined }) satisfies string; | ||
fastStableStringify({ foo: 'bar' }) satisfies string; | ||
fastStableStringify([1, 2, 3]) satisfies string; | ||
fastStableStringify(1n) satisfies string; | ||
fastStableStringify(BigInt(1)) satisfies string; | ||
fastStableStringify(1) satisfies string; | ||
fastStableStringify(5e-324) satisfies string; | ||
fastStableStringify(0xdeadbeef) satisfies string; | ||
fastStableStringify(true) satisfies string; | ||
fastStableStringify(false) satisfies string; | ||
fastStableStringify('string') satisfies string; | ||
fastStableStringify(new Date()) satisfies string; | ||
fastStableStringify(null) satisfies string; |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"declaration": true, | ||
"declarationMap": true, | ||
"emitDeclarationOnly": true, | ||
"outDir": "./dist/types" | ||
}, | ||
"extends": "./tsconfig.json", | ||
"include": ["src/index.ts", "src/types"] | ||
} |
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