diff --git a/flow-report/test/App-test.tsx b/flow-report/test/App-test.tsx index b52025fef338..b44dcf658ccf 100644 --- a/flow-report/test/App-test.tsx +++ b/flow-report/test/App-test.tsx @@ -7,11 +7,10 @@ import fs from 'fs'; import {App} from '../App'; import {render} from '@testing-library/preact'; -import {LH_ROOT} from '../../root'; const flowResult = JSON.parse( fs.readFileSync( - `${LH_ROOT}/lighthouse-core/test/fixtures/fraggle-rock/reports/sample-lhrs.json`, + `${__dirname}/../../lighthouse-core/test/fixtures/fraggle-rock/reports/sample-lhrs.json`, 'utf-8' ) ); diff --git a/flow-report/tsconfig.json b/flow-report/tsconfig.json index b6d932d02a0c..318d8186fcd3 100644 --- a/flow-report/tsconfig.json +++ b/flow-report/tsconfig.json @@ -1,14 +1,37 @@ { - "extends": "../tsconfig", "compilerOptions": { + "composite": true, + "outDir": "../.tmp/tsbuildinfo/flow-report", + "emitDeclarationOnly": true, + "declarationMap": true, + + // Limit to base JS and DOM defs. + "lib": ["es2020", "dom", "dom.iterable"], + // Selectively include types from node_modules. + "types": ["node", "jest"], + "target": "es2020", + "module": "es2020", + "moduleResolution": "node", + "esModuleInterop": true, + + "allowJs": true, + "checkJs": true, + "strict": true, + // TODO: remove the next line to be fully `strict`. + "useUnknownInCatchVariables": false, + + // "listFiles": true, + // "noErrorTruncation": true, + "extendedDiagnostics": true, + "jsx": "react-jsx", "jsxImportSource": "preact", - "esModuleInterop": true, - "composite": false }, "include": [ "**/*.tsx", "./types", - "../types" + ], + "references": [ + {"path": "../types/lhr/"}, ], } diff --git a/flow-report/types/flow-report.d.ts b/flow-report/types/flow-report.d.ts index ce44578f091e..5c64d25cdd4c 100644 --- a/flow-report/types/flow-report.d.ts +++ b/flow-report/types/flow-report.d.ts @@ -4,13 +4,20 @@ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import FlowResult from '../../types/lhr/flow'; +import FlowResult_ from '../../types/lhr/flow'; +import LHResult from '../../types/lhr/lhr'; declare global { interface Window { - __LIGHTHOUSE_FLOW_JSON__: FlowResult; + __LIGHTHOUSE_FLOW_JSON__: FlowResult_; __initLighthouseFlowReport__: () => void; } + + // Expose global types in LH namespace. + module LH { + export import Result = LHResult; + export type FlowResult = FlowResult_; + } } export {}; diff --git a/package.json b/package.json index 632b20c1db2f..d48755779cac 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "dogfood-lhci": "./lighthouse-core/scripts/dogfood-lhci.sh", "timing-trace": "node lighthouse-core/scripts/generate-timing-trace.js", "changelog": "conventional-changelog --config ./build/changelog-generator/index.js --infile changelog.md --same-file", - "type-check": "tsc --build ./ report/ lighthouse-viewer/ && tsc -p lighthouse-treemap/ && tsc -p flow-report/", + "type-check": "tsc --build ./ report/ lighthouse-viewer/ flow-report/ && tsc -p lighthouse-treemap/", "i18n:checks": "./lighthouse-core/scripts/i18n/assert-strings-collected.sh", "i18n:collect-strings": "node lighthouse-core/scripts/i18n/collect-strings.js", "update:lantern-baseline": "node lighthouse-core/scripts/lantern/update-baseline-lantern-values.js",