Add browser-or-node types (#41910)

This commit is contained in:
Jussi Kinnula
2020-01-30 00:14:43 +02:00
committed by GitHub
parent 6127fb8e61
commit 6f1f5c8b4f
4 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
import { isBrowser, isWebWorker, isNode } from 'browser-or-node';
if (isBrowser) {
console.log('isBrowser');
}
if (isWebWorker) {
console.log('isBrowser');
}
if (isNode) {
console.log('isBrowser');
}

9
types/browser-or-node/index.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
// Type definitions for browser-or-node 1.2
// Project: https://github.com/flexdinesh/browser-or-node
// Definitions by: Jussi Kinnula <https://github.com/jussikinnula>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
export const isBrowser: boolean;
export const isWebWorker: boolean;
export const isNode: boolean;

View File

@@ -0,0 +1,24 @@
{
"files": [
"index.d.ts",
"browser-or-node-tests.ts"
],
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
}

View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}