types: Add npm run check-types command

This allows to run typescript checking on the project to make sure the
types are functional.
pull/22402/head
Julien Rebetez 2023-02-15 11:20:05 +01:00
parent 9651336e7e
commit cc3e3e2827
3 changed files with 49 additions and 0 deletions

View File

@ -26,6 +26,7 @@
"dist": "npm run clean && npm run build:file && npm run lint && webpack --config build/webpack.conf.js && webpack --config build/webpack.common.js && webpack --config build/webpack.component.js && npm run build:utils && npm run build:umd && npm run build:theme", "dist": "npm run clean && npm run build:file && npm run lint && webpack --config build/webpack.conf.js && webpack --config build/webpack.common.js && webpack --config build/webpack.component.js && npm run build:utils && npm run build:umd && npm run build:theme",
"i18n": "node build/bin/i18n.js", "i18n": "node build/bin/i18n.js",
"lint": "eslint src/**/* test/**/* packages/**/* build/**/* --quiet", "lint": "eslint src/**/* test/**/* packages/**/* build/**/* --quiet",
"check-types": "tsc --noEmit -p .",
"pub": "npm run bootstrap && sh build/git-release.sh && sh build/release.sh && node build/bin/gen-indices.js", "pub": "npm run bootstrap && sh build/git-release.sh && sh build/release.sh && node build/bin/gen-indices.js",
"test": "npm run lint && npm run build:theme && cross-env CI_ENV=/dev/ BABEL_ENV=test karma start test/unit/karma.conf.js --single-run", "test": "npm run lint && npm run build:theme && cross-env CI_ENV=/dev/ BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
"test:watch": "npm run build:theme && cross-env BABEL_ENV=test karma start test/unit/karma.conf.js" "test:watch": "npm run build:theme && cross-env BABEL_ENV=test karma start test/unit/karma.conf.js"

12
tsconfig.json Normal file
View File

@ -0,0 +1,12 @@
{
"compilerOptions": {
"strict": true,
"allowJs": true,
"noEmit": true,
"paths": {
"resize-observer-polyfill": ["./types/overrides/resize-observer-polyfill"]
}
},
"include": ["src/**/*", "packages/**/*", "types/**/*"],
"exclude": ["node_modules/**/*"]
}

View File

@ -0,0 +1,36 @@
// resize-observer-polyfill types conflict with typescript's own typings on typescript > 4.2.2
// See https://github.com/que-etc/resize-observer-polyfill/issues/83
//
// So we override the typings for resize-observer-polyfill and remove the DOMRectReadOnly interface
// definition
// https://raw.githubusercontent.com/que-etc/resize-observer-polyfill/master/src/index.d.ts
declare global {
interface ResizeObserverCallback {
(entries: ResizeObserverEntry[], observer: ResizeObserver): void
}
interface ResizeObserverEntry {
readonly target: Element;
readonly contentRect: DOMRectReadOnly;
}
interface ResizeObserver {
observe(target: Element): void;
unobserve(target: Element): void;
disconnect(): void;
}
}
declare var ResizeObserver: {
prototype: ResizeObserver;
new(callback: ResizeObserverCallback): ResizeObserver;
}
interface ResizeObserver {
observe(target: Element): void;
unobserve(target: Element): void;
disconnect(): void;
}
export default ResizeObserver;