mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
🤖 Merge PR #63825 [add] Add typings for add npm package by @LeoDog896
* [add] Add typings * Change arrays to readonly * Use = instead of default for export * Properly export default function using namespaces
This commit is contained in:
26
types/add/add-tests.ts
Normal file
26
types/add/add-tests.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import add = require("add");
|
||||
const { dumbSum, fastTwoSum, nextPowerTwo } = add;
|
||||
|
||||
// $ExpectType number
|
||||
add([0.1, 0.2]);
|
||||
|
||||
// @ts-expect-error
|
||||
add(15, 14);
|
||||
|
||||
// $ExpectType number
|
||||
dumbSum([15, 14]);
|
||||
|
||||
// @ts-expect-error
|
||||
dumbSum(20, "a");
|
||||
|
||||
// $ExpectType [number, number, null]
|
||||
fastTwoSum(1 / 3, 1 / 6);
|
||||
|
||||
// @ts-expect-error
|
||||
fastTwoSum(1 / 3);
|
||||
|
||||
// $ExpectType number
|
||||
nextPowerTwo(1534);
|
||||
|
||||
// @ts-expect-error
|
||||
nextPowerTwo(new Symbol());
|
||||
19
types/add/index.d.ts
vendored
Normal file
19
types/add/index.d.ts
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// Type definitions for add 2.0
|
||||
// Project: https://github.com/ben-ng/add
|
||||
// Definitions by: Tristan F. <https://github.com/LeoDog896>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function accSum(numbers: ReadonlyArray<number>): number;
|
||||
|
||||
export = accSum;
|
||||
|
||||
declare namespace accSum {
|
||||
function dumbSum(numbers: ReadonlyArray<number>): number;
|
||||
function fastTwoSum(a: number, b: number): [number, number, null];
|
||||
|
||||
/**
|
||||
* Finds the immediate power of 2 that is larger than p
|
||||
* in a fast way
|
||||
*/
|
||||
function nextPowerTwo(p: number): number;
|
||||
}
|
||||
23
types/add/tsconfig.json
Normal file
23
types/add/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"add-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/add/tslint.json
Normal file
1
types/add/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "@definitelytyped/dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user