Skip to content

Commit

Permalink
[New] add types
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Dec 2, 2024
1 parent f7b14be commit ab38e78
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
root = true

[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 150

[CHANGELOG.md]
indent_style = space
indent_size = 2

[*.json]
max_line_length = off

[Makefile]
max_line_length = off
11 changes: 11 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type primitive = string | number | bigint | boolean | symbol | null | undefined;

declare function whichBoxedPrimitive(value: primitive): null;
declare function whichBoxedPrimitive(value: BigInt): 'BigInt';
declare function whichBoxedPrimitive(value: Boolean): 'Boolean';
declare function whichBoxedPrimitive(value: Number): 'Number';
declare function whichBoxedPrimitive(value: String): 'String';
declare function whichBoxedPrimitive(value: Symbol): 'Symbol';
declare function whichBoxedPrimitive(value: unknown): undefined;

export = whichBoxedPrimitive;
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var isBoolean = require('is-boolean-object');
var isSymbol = require('is-symbol');
var isBigInt = require('is-bigint');

/** @type {import('.')} */
// eslint-disable-next-line consistent-return
module.exports = function whichBoxedPrimitive(value) {
// eslint-disable-next-line eqeqeq
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"prepublishOnly": "safe-publish-latest",
"prepublish": "not-in-publish || npm run prepublishOnly",
"lint": "eslint --ext=js,mjs .",
"postlint": "tsc -p . && attw -P",
"pretest": "npm run lint",
"tests-only": "nyc tape 'test/**/*.js'",
"test": "npm run tests-only",
Expand Down Expand Up @@ -44,7 +45,12 @@
"is-symbol": "^1.1.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.0",
"@ljharb/eslint-config": "^21.1.1",
"@ljharb/tsconfig": "^0.2.0",
"@types/for-each": "^0.3.3",
"@types/object-inspect": "^1.13.0",
"@types/tape": "^5.6.5",
"auto-changelog": "^2.5.0",
"encoding": "^0.1.13",
"es-value-fixtures": "^1.5.0",
Expand All @@ -55,7 +61,8 @@
"nyc": "^10.3.2",
"object-inspect": "^1.13.3",
"safe-publish-latest": "^2.0.0",
"tape": "^5.9.0"
"tape": "^5.9.0",
"typescript": "next"
},
"auto-changelog": {
"output": "CHANGELOG.md",
Expand Down
9 changes: 9 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "@ljharb/tsconfig",
"compilerOptions": {
"target": "ES2021",
},
"exclude": [
"coverage"
]
}

0 comments on commit ab38e78

Please sign in to comment.