0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Updated collections package to use .d.ts for external lib types

Rather than using `require` we can add a type definition file, this allows us
to add custom types in the future if we want. We need to add some config for
ts-node to pick up the types correctly.
This commit is contained in:
Fabien "egg" O'Carroll 2023-05-24 12:45:43 -04:00
parent 7000b8214b
commit b58dac262e
4 changed files with 8 additions and 3 deletions

View file

@ -10,7 +10,7 @@
"dev": "tsc --watch --preserveWatchOutput --sourceMap",
"build": "tsc",
"prepare": "tsc",
"test:unit": "NODE_ENV=testing c8 --src src --all --exclude 'test/' --check-coverage --100 --reporter text --reporter cobertura mocha -r ts-node/register './test/**/*.test.ts'",
"test:unit": "NODE_ENV=testing c8 --src src --all --check-coverage --100 --reporter text --reporter cobertura mocha -r ts-node/register './test/**/*.test.ts'",
"test": "yarn test:types && yarn test:unit",
"test:types": "tsc --noEmit",
"lint:code": "eslint src/ --ext .ts --cache",

View file

@ -1,7 +1,7 @@
// have to use requires until there are type definitions for these modules
const {ValidationError} = require('@tryghost/errors');
const tpl = require('@tryghost/tpl');
import {ValidationError} from '@tryghost/errors';
import tpl from '@tryghost/tpl';
import ObjectID from 'bson-objectid';

2
ghost/collections/src/libraries.d.ts vendored Normal file
View file

@ -0,0 +1,2 @@
declare module '@tryghost/errors';
declare module '@tryghost/tpl';

View file

@ -1,4 +1,7 @@
{
"ts-node": {
"files": true
},
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */