Skip to content

Commit

Permalink
@atomic-layout/core: Handles global __PROD__ flag typing-wise
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Feb 12, 2020
1 parent 5c9a772 commit 7459970
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/atomic-layout-core/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Global flag that indicates production environment.
*/
declare const __PROD__: string
2 changes: 2 additions & 0 deletions packages/atomic-layout-core/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Perform all unit tests in production environment
global.__PROD__ = true
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export default function generateComponents(
return components[areaName]
}

// @ts-ignore-line
if (!__PROD__) {
// tslint:disable-next-line
console.warn(
'Prevented render of the area "%s", which is not found in the template definition. Please render one of the existing areas ("%s"), or modify the template to include "%s".',
areaName,
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic-layout-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"baseUrl": ".",
"types": ["node", "jest"]
},
"include": ["src/**/*"],
"include": ["global.d.ts", "src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}

0 comments on commit 7459970

Please sign in to comment.