Fix build error due to non-existing window.loadTimeData
We need to import loadTimeData from the internal module and use it from there instead of accessing window.loadTimeData. ERROR in /home/work/brave-browser/src/brave/components/brave_welcome_ui/reducers/welcome_reducer.ts in /home/work/brave-browser/src/brave/components/brave_welcome_ui/reducers/welcome_reducer.ts(47,40) TS2339: Property \'loadTimeData\' does not exist on type \'Window & typeof globalThis\'. npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! brave-core@1.28.4 web-ui: `webpack --config components/webpack/webpack.config.js --progress --colors "--mode=development" "brave_welcome=/home/work/brave-browser/src/brave/components/brave_welcome_ui/brave_welcome.tsx"` Traceback (most recent call last): File "/home/work/brave-browser/src/out/Component/../../brave/script/transpile-web-ui.py", line 118, in <module> sys.exit(main()) File "/home/work/brave-browser/src/out/Component/../../brave/script/transpile-web-ui.py", line 31, in main transpile_web_uis(args.production, webpack_gen_dir, root_gen_dir, File "/home/work/brave-browser/src/out/Component/../../brave/script/transpile-web-ui.py", line 98, in transpile_web_uis execute_stdout(args, env) File "/home/work/brave-browser/src/brave/script/lib/util.py", line 192, in execute_stdout execute(argv, env) File "/home/work/brave-browser/src/brave/script/lib/util.py", line 180, in execute raise e File "/home/work/brave-browser/src/brave/script/lib/util.py", line 173, in execute output = subprocess.check_output(argv, stderr=subprocess.STDOUT, File "/usr/lib/python3.9/subprocess.py", line 424, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/usr/lib/python3.9/subprocess.py", line 528, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['npm', 'run', 'web-ui', '--', '--mode=development', 'brave_welcome=/home/work/brave-browser/src/brave/components/brave_welcome_ui/brave_welcome.tsx']' returned non-zero exit status 2.
This commit is contained in:
committed by
mkarolin
parent
2930d9dcda
commit
9f67011e35
@@ -6,6 +6,7 @@
|
||||
import { Reducer } from 'redux'
|
||||
|
||||
// Constants
|
||||
import { loadTimeData } from '../../common/loadTimeData'
|
||||
import { types } from '../constants/welcome_types'
|
||||
|
||||
// Utils
|
||||
@@ -44,7 +45,7 @@ const welcomeReducer: Reducer<Welcome.State | undefined> = (state: Welcome.State
|
||||
case types.IMPORT_DEFAULT_SEARCH_PROVIDERS_SUCCESS:
|
||||
// TODO(bsclifton): remove when ready for other regions
|
||||
const showBraveSearch: boolean =
|
||||
['US', 'CA'].includes(window.loadTimeData.getString('countryString'))
|
||||
['US', 'CA'].includes(loadTimeData.getString('countryString'))
|
||||
// Only show Brave Search during onboarding for US/CA
|
||||
const filteredSearchList = payload.filter((item: any) => {
|
||||
return !(item.name && item.name.startsWith('Brave ') && item.canBeRemoved)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import welcomeReducer from '../../../brave_welcome_ui/reducers/welcome_reducer'
|
||||
import * as actions from '../../../brave_welcome_ui/actions/welcome_actions'
|
||||
import * as storage from '../../../brave_welcome_ui/storage'
|
||||
import { loadTimeData } from '../../../common/loadTimeData'
|
||||
import { types } from '../../../brave_welcome_ui/constants/welcome_types'
|
||||
import { mockSearchProviders, mockImportSources } from '../../testData'
|
||||
|
||||
@@ -141,7 +142,7 @@ describe('welcomeReducer', () => {
|
||||
{ name: 'Brave Search beta', canBeRemoved: true }
|
||||
]
|
||||
let countryString: string = 'US'
|
||||
window.loadTimeData = {
|
||||
loadTimeData = {
|
||||
getString: (fieldName: string) => {
|
||||
switch (fieldName) {
|
||||
case 'countryString': return countryString
|
||||
@@ -152,7 +153,7 @@ describe('welcomeReducer', () => {
|
||||
let spy: jest.SpyInstance
|
||||
|
||||
beforeEach(() => {
|
||||
spy = jest.spyOn(window.loadTimeData, 'getString')
|
||||
spy = jest.spyOn(loadTimeData, 'getString')
|
||||
})
|
||||
afterEach(() => {
|
||||
spy.mockRestore()
|
||||
|
||||
Reference in New Issue
Block a user