Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report: isolate flow-report type checking #12952

Merged
merged 3 commits into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions flow-report/test/App-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Copy link
Member Author

@brendankenny brendankenny Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to #12940 (comment), root.js isn't accessible without importing all of core, so this works for now.

I also don't have a good mental model for where tsx files live on the commonjs <-> esmodules spectrum and what works in them and what doesn't. Does it just depend on the bundler?

'utf-8'
)
);
Expand Down
31 changes: 27 additions & 4 deletions flow-report/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
{
"extends": "../tsconfig",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll switch this back to extending and move most of this back to a tsconfig-base.json or whatever in a follow up

"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/"},
],
}
11 changes: 9 additions & 2 deletions flow-report/types/flow-report.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down