Skip to content
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

Add typings for module and submodules #21

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hardware-concurrency/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export function useHardwareConcurrency(): { unsupported: true } | { unsupported: false, numberOfLogicalProcessors: number }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stramel

Could we add semicolon at the end of lines for the purpose of consistency?

4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './hardware-concurrency'
export * from './memory'
export * from './network'
export * from './save-data'
10 changes: 10 additions & 0 deletions memory/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export interface MemoryStatus {
deviceMemory: number,
totalJSHeapSize: number | null,
usedJSHeapSize: number | null,
jsHeapSizeLimit: number | null
}

export function useMemoryStatus(initialMemoryStatus?: MemoryStatus): { unsupported: true } & Partial<MemoryStatus> | {
unsupported: false,
} & MemoryStatus
6 changes: 6 additions & 0 deletions network/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type EffectiveConnectionType = 'slow-2g' | '2g' | '3g' | '4g'

export function useNetworkStatus(initialEffectiveConnectionType?: EffectiveConnectionType | null): {
unsupported: boolean,
effectiveConnectionType: EffectiveConnectionType | null
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"main": "dist/index.js",
"module": "dist/index.module.js",
"unpkg": "dist/index.umd.js",
"typings": "index.d.ts",
"source": "index.js",
"typings": "index.d.ts",
Copy link
Contributor

@anton-karlovskiy anton-karlovskiy Mar 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stramel

It looks duplicated with line 12.
Can we put the type definition file (index.d.ts) inside typings directory, for example, "typings": "typings/index.d.ts"?

"scripts": {
"build": "microbundle",
"dev": "microbundle watch",
Expand All @@ -35,4 +37,4 @@
"react",
"performance"
]
}
}
1 change: 1 addition & 0 deletions save-data/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export function useSaveData(initialSaveDataStatus?: boolean | null): { unsupported: boolean, saveData: boolean | null }