Skip to content

Commit a8e5a0e

Browse files
authored
Initial use of PCore typedef (#357)
Initial use of PCore typedef
1 parent a96e536 commit a8e5a0e

File tree

7 files changed

+28
-10
lines changed

7 files changed

+28
-10
lines changed

.eslintrc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"project": "tsconfig.json",
66
"ecmaVersion": 13
77
},
8+
"globals": {
9+
"PCore": "readonly"
10+
},
811
"settings": {
912
"import/resolver": {
1013
"typescript": {},
@@ -80,7 +83,7 @@
8083
"no-alert": "error",
8184
"no-console": "error",
8285
"no-fallthrough": "error",
83-
"no-undef": "error",
86+
"no-undef": "warn",
8487
"no-unused-vars": "error",
8588
"no-var": "error",
8689
"prefer-const": "error",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"@pega/configs": "^0.4.0",
8080
"@pega/dx-component-builder-sdk": "~8.23.11",
8181
"@pega/eslint-config": "^0.4.0",
82+
"@pega/pcore-pconnect-typedefs": "latest",
8283
"@pega/prettier-config": "^0.4.0",
8384
"@pega/react-sdk-overrides": "~8.23.10",
8485
"@pega/stylelint-config": "^0.4.0",

src/samples/Embedded/EmbeddedTopLevel/index.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,9 @@ import { getSdkConfig, SdkConfigAccess } from '@pega/react-sdk-components/lib/co
1717
import { getSdkComponentMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
1818
import localSdkComponentMap from '../../../../sdk-local-component-map';
1919

20-
21-
22-
// declare var gbLoggedIn: boolean;
23-
// declare var login: Function;
24-
// declare var logout: Function;
25-
26-
declare const PCore: any;
2720
declare const myLoadMashup: any;
2821

22+
2923
const useStyles = makeStyles((theme) => ({
3024
embedTopRibbon: {
3125
display: 'none',

src/samples/FullPortal/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { loginIfNecessary } from '@pega/react-sdk-components/lib/components/help
1212
import { getSdkComponentMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
1313
import localSdkComponentMap from '../../../sdk-local-component-map';
1414

15-
declare const PCore: any;
15+
1616
declare const myLoadPortal: any;
1717
declare const myLoadDefaultPortal: any;
1818

src/types/global.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// global.d.ts - Establishes a PCore global using the type info declared in @pega/pcore-connect-typedefs
2+
// imports the default exported type (called PCore in the file) as the named type "PCoreType" (to avoid confusion)
3+
import PCoreType from '@pega/pcore-pconnect-typedefs/types/pcore';
4+
5+
// declare that the running app can expect there to be a PCore constant that is of type PCoreType
6+
declare global { const PCore: typeof PCoreType }
7+
8+
// tells TypeScript to export as a "module" - special syntax that's not well documented
9+
export { };

src/types/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type PConnect from '@pega/pcore-pconnect-typedefs/types/pconn';
2+
3+
// This gives us a place to have each component extend its props (from BaseProps)
4+
// such that every component will be expected to have a getPConnect() function
5+
// that returns a PConnect object. (new/better way of doing .propTypes).
6+
// This BaseProps can be extended to include other props that we know are in every component
7+
export interface BaseProps {
8+
getPConnect: () => typeof PConnect;
9+
}

tsconfig.build.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"noEmit": false,
1212
"composite": true,
1313
//"rootDir": "./src",
14-
"outDir": "./lib"
14+
"outDir": "./lib",
15+
// "skipLibCheck" must be true in order to not see errors in the @pega/pcore-pconnect-typedefs files themselves
16+
"skipLibCheck": true,
1517
},
1618
"files" : [ "./sdk-local-component-map.js"]
1719
}

0 commit comments

Comments
 (0)