-
Notifications
You must be signed in to change notification settings - Fork 41
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
TS types #45
Merged
Merged
TS types #45
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3662440
Add TS types
kibertoad 3408ead
Fix npm script
kibertoad baf7c8c
Replaces `files` with `.npmignore`
kibertoad b86de99
Second iteration of TS types
kibertoad 95e9fc4
Merge branch 'master' of https://github.com/mcollina/sonic-boom into …
kibertoad b915330
Add "the infamous triplet"
kibertoad 5d36f2a
Fix wording
kibertoad b6b4194
Improve assertion
kibertoad f3338bf
Merge branch 'master' of https://github.com/mcollina/sonic-boom into …
kibertoad 6b399e5
Make script entries consistent
kibertoad 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
types/index.d.ts | ||
types/index.test-d.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
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 |
---|---|---|
|
@@ -61,3 +61,4 @@ package-lock.json | |
|
||
# node clinic | ||
*clinic* | ||
/.idea/ |
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 @@ | ||
.editorconfig | ||
.gitattributes | ||
.git | ||
.DS_Store | ||
.gitignore | ||
.github | ||
.dependabot | ||
.clinic | ||
tsconfig.json | ||
types/index.test-d.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
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,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es6", | ||
"lib": [ "es2015" ], | ||
"module": "commonjs", | ||
"noEmit": true, | ||
"strict": true | ||
}, | ||
"include": [ | ||
"./types/index.test-d.ts", | ||
"./types/index.d.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,48 @@ | ||
// Type definitions for sonic-boom 0.7 | ||
// Definitions by: Alex Ferrando <https://github.com/alferpal> | ||
// Igor Savin <https://github.com/kibertoad> | ||
/// <reference types="node"/> | ||
|
||
import { EventEmitter } from 'events'; | ||
|
||
export default SonicBoom; | ||
|
||
export class SonicBoom extends EventEmitter { | ||
/** | ||
* @param [fileDescriptor] File path or numerical file descriptor | ||
* relative protocol is enabled. Default: process.stdout | ||
* @returns a new sonic-boom instance | ||
*/ | ||
constructor(fileDescriptor: string | number, minLength?: number, sync?: boolean) | ||
|
||
/** | ||
* Writes the string to the file. It will return false to signal the producer to slow down. | ||
*/ | ||
write(string: string): void; | ||
|
||
/** | ||
* Writes the current buffer to the file if a write was not in progress. | ||
* Do nothing if minLength is zero or if it is already writing. | ||
*/ | ||
flush(): void; | ||
|
||
/** | ||
* Reopen the file in place, useful for log rotation. | ||
*/ | ||
reopen(fileDescriptor?: string | number): void; | ||
|
||
/** | ||
* Flushes the buffered data synchronously. This is a costly operation. | ||
*/ | ||
flushSync(): void; | ||
|
||
/** | ||
* Closes the stream, the data will be flushed down asynchronously | ||
*/ | ||
end(): void; | ||
|
||
/** | ||
* Closes the stream immediately, the data is not flushed. | ||
*/ | ||
destroy(): void; | ||
} |
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,34 @@ | ||
import { expectType } from "tsd"; | ||
import SonicBoom, { SonicBoom as SonicBoomNamed } from "../"; | ||
import SonicBoomDefault from "../"; | ||
import * as SonicBoomStar from "../"; | ||
import SonicBoomCjsImport = require ("../"); | ||
const SonicBoomCjs = require("../"); | ||
const { SonicBoom: SonicBoomCjsNamed } = require('SonicBoom') | ||
|
||
const sonic = new SonicBoom(1); | ||
|
||
expectType<SonicBoom>(new SonicBoomNamed(1)); | ||
expectType<SonicBoom>( new SonicBoomDefault(1)); | ||
expectType<SonicBoom>( new SonicBoomStar.SonicBoom(1)); | ||
expectType<SonicBoom>( new SonicBoomStar.default(1)); | ||
expectType<SonicBoom>( new SonicBoomCjsImport.SonicBoom(1)); | ||
expectType<SonicBoom>( new SonicBoomCjsImport.default(1)); | ||
expectType<any>( new SonicBoomCjs(1)); | ||
expectType<any>( new SonicBoomCjsNamed(1)); | ||
|
||
sonic.write('hello sonic\n'); | ||
|
||
sonic.flush(); | ||
|
||
sonic.flushSync(); | ||
|
||
sonic.reopen(); | ||
|
||
sonic.end(); | ||
|
||
sonic.destroy(); | ||
|
||
const extraSonic = new SonicBoom(1, 0, true); | ||
|
||
extraSonic.write('extra sonic\n'); |
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.
Nice! We should add this import test in every package we maintain :)