File tree Expand file tree Collapse file tree
packages/pluggable-widgets-tools Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 },
1313 "scripts" : {
1414 "prepack" : " shx rm -rf dist && tsc" ,
15- "test" : " jest"
15+ "typecheck:test-config" : " tsc -p test-config/tsconfig.json" ,
16+ "test" : " tsc -p test-config/tsconfig.json && jest"
1617 },
1718 "files" : [
1819 " bin" ,
Original file line number Diff line number Diff line change 1- // Runtime mock for the types-only `mendix` package, whose real entry throws
2- // ("This package should not be used in the runtime"). `@swc/jest` can't inline
3- // the ambient `const enum ValueStatus`, so it emits a live `require("mendix")`
4- // that needs this safe module exporting the enum values widget code uses.
5- //
6- // Keep values in sync with node_modules/mendix/index.d.ts.
1+ // @ts -check
2+ // Runtime mock for the types-only `mendix` package (its real entry throws).
3+ // Stays plain JS because it ships inside the consumer's node_modules, where
4+ // jest won't transform TypeScript. The JSDoc `@type` annotations check the
5+ // values against `mendix`'s types (repo-only, via test-config/tsconfig.json)
6+ // and are erased at runtime.
7+
8+ /** @typedef {typeof import("mendix") } MendixModule */
9+
10+ /**
11+ * Map an enum's type to `{ [Member]: itsStringValue }`.
12+ * @template E
13+ * @typedef {{ [K in keyof E]: `${Extract<E[K], string>}` } } EnumMock
14+ */
15+
716module . exports = {
17+ /** @type {EnumMock<MendixModule["ValueStatus"]> } */
818 ValueStatus : {
919 Available : "available" ,
1020 Unavailable : "unavailable" ,
1121 Loading : "loading"
1222 } ,
23+ /** @type {EnumMock<MendixModule["FormatterType"]> } */
1324 FormatterType : {
1425 Number : "number" ,
1526 DateTime : "datetime"
Original file line number Diff line number Diff line change 1+ {
2+ "extends" : " ../configs/tsconfig.base" ,
3+ "compilerOptions" : {
4+ "noEmit" : true ,
5+ "allowJs" : true ,
6+ "checkJs" : true ,
7+ "moduleResolution" : " bundler"
8+ },
9+ "include" : [" __mocks__/mendix.js" ]
10+ }
You can’t perform that action at this time.
0 commit comments