mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 13:08:40 +08:00
We bundled our own copy of the `truth-helpers` addon and were about to
hand-convert it to TypeScript. Since the official `ember-truth-helpers`
package already ships the precise return types we wanted (`or`/`and`
resolve to the value union of their arguments rather than `boolean`)
along with the `forceNumber` option, this backs our copy with the
package instead of reimplementing it.
`discourse/truth-helpers` keeps its existing import paths: each helper
module re-exports the package default, so both `import { or } from
"discourse/truth-helpers"` and `{{or ...}}` continue to work. `has` and
`includes` stay local (the package has no equivalent), and
`xor`/`isArray`/`isEmpty`/`isEqual` are now exposed.
`@discourse/types` gains a bare `./truth-helpers` export so the
re-exported types resolve for plugins and themes authored in TypeScript.
Rather than adding `ember-truth-helpers` as a runtime dependency of the
types package, its declarations are bundled into the `external-types`
set so `@discourse/types` carries the types itself; this required the
external-types generator to strip the modern `.ts`/`.mts`/`.cts` import
extensions that `ember-truth-helpers` v5's declarations use.
A dedicated `type-tests/` directory holds `expect-type` assertions
checked by `pnpm lint:types`; since `or`/`and` are class-based helpers,
their assertions are written in template (`.gts`) form.
59 lines
1.5 KiB
JSON
Vendored
59 lines
1.5 KiB
JSON
Vendored
{
|
|
"name": "@discourse/types",
|
|
"version": "0.0.0",
|
|
"description": "Types only",
|
|
"repository": "https://github.com/discourse/discourse",
|
|
"license": "GPL-2.0-only",
|
|
"author": "Discourse",
|
|
"publishConfig": {
|
|
"access": "public"
|
|
},
|
|
"type": "module",
|
|
"files": [
|
|
"declarations",
|
|
"external-types",
|
|
"tsconfig-plugin.json"
|
|
],
|
|
"scripts": {
|
|
"compile-dts-generator": "tsc dts-generator.ts --target esnext --moduleResolution nodenext --module nodenext",
|
|
"generate-external-types": "node generate-external-types.js",
|
|
"generate-external": "pnpm compile-dts-generator && pnpm generate-external-types"
|
|
},
|
|
"exports": {
|
|
"./tsconfig-plugin": "./tsconfig-plugin.json",
|
|
"./tests/*": {
|
|
"types": "./declarations/tests/*.d.ts"
|
|
},
|
|
"./admin/*": {
|
|
"types": "./declarations/admin/*.d.ts"
|
|
},
|
|
"./dialog-holder/*": {
|
|
"types": "./declarations/dialog-holder/*.d.ts"
|
|
},
|
|
"./float-kit/*": {
|
|
"types": "./declarations/float-kit/*.d.ts"
|
|
},
|
|
"./select-kit/*": {
|
|
"types": "./declarations/select-kit/*.d.ts"
|
|
},
|
|
"./truth-helpers": {
|
|
"types": "./declarations/truth-helpers/index.d.ts"
|
|
},
|
|
"./truth-helpers/*": {
|
|
"types": "./declarations/truth-helpers/*.d.ts"
|
|
},
|
|
"./*": {
|
|
"types": "./declarations/app/*.d.ts"
|
|
}
|
|
},
|
|
"devDependencies": {
|
|
"@types/node": "^25.3.3",
|
|
"compare-versions": "^6.1.1"
|
|
},
|
|
"engines": {
|
|
"node": ">= 20",
|
|
"npm": "please-use-pnpm",
|
|
"yarn": "please-use-pnpm",
|
|
"pnpm": "^10"
|
|
}
|
|
}
|