Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
ref: Enable noUncheckedIndexedAccess TS config#12461
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
911b3f011d55ad255e0d52a518a7686a898e088a140ee08f7e22cffdFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* eslint-disable no-console */ | ||
| const { execSync } = require('child_process'); | ||
| const { join } = require('path'); | ||
| const { writeFileSync } = require('fs'); | ||
| const cwd = join(__dirname, '../../..'); | ||
| const tsVersion = process.argv[2] || '3.8'; | ||
| console.log(`Installing typescript@${tsVersion}...`); | ||
| execSync(`yarn add --dev --ignore-workspace-root-check typescript@${tsVersion}`, { stdio: 'inherit', cwd }); | ||
| console.log('Removing unsupported tsconfig options...'); | ||
| const baseTscConfigPath = join(cwd, 'packages/typescript/tsconfig.json'); | ||
| const tsConfig = require(baseTscConfigPath); | ||
| // TS 3.8 fails build when it encounteres a config option it does not understand, so we remove it :( | ||
| delete tsConfig.compilerOptions.noUncheckedIndexedAccess; | ||
| writeFileSync(baseTscConfigPath, JSON.stringify(tsConfig, null, 2)); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "extends": "../tsconfig.test.json", | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -77,28 +77,8 @@ function _fetchResponseHandler( | ||
| let requestHeaders, responseHeaders, requestCookies, responseCookies; | ||
| if (_shouldSendDefaultPii()) { | ||
| [{ headers: requestHeaders, cookies: requestCookies }, { headers: responseHeaders, cookies: responseCookies }] = [ | ||
| { cookieHeader: 'Cookie', obj: request }, | ||
| { cookieHeader: 'Set-Cookie', obj: response }, | ||
| ].map(({ cookieHeader, obj }) => { | ||
| const headers = _extractFetchHeaders(obj.headers); | ||
| let cookies; | ||
| try { | ||
| const cookieString = headers[cookieHeader] || headers[cookieHeader.toLowerCase()] || undefined; | ||
| if (cookieString) { | ||
| cookies = _parseCookieString(cookieString); | ||
| } | ||
| } catch (e) { | ||
| DEBUG_BUILD && logger.log(`Could not extract cookies from header ${cookieHeader}`); | ||
| } | ||
| return { | ||
| headers, | ||
| cookies, | ||
| }; | ||
| }); | ||
| [requestHeaders, requestCookies] = _parseCookieHeaders('Cookie', request); | ||
| [responseHeaders, responseCookies] = _parseCookieHeaders('Set-Cookie', response); | ||
Comment on lines
+80
to
+81
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice refactor! | ||
| } | ||
| const event = _createEvent({ | ||
| @@ -115,6 +95,26 @@ function _fetchResponseHandler( | ||
| } | ||
| } | ||
| function _parseCookieHeaders( | ||
| cookieHeader: string, | ||
| obj: Request | Response, | ||
| ): [Record<string, string>, Record<string, string> | undefined] { | ||
| const headers = _extractFetchHeaders(obj.headers); | ||
| let cookies; | ||
| try { | ||
| const cookieString = headers[cookieHeader] || headers[cookieHeader.toLowerCase()] || undefined; | ||
| if (cookieString) { | ||
| cookies = _parseCookieString(cookieString); | ||
| } | ||
| } catch (e) { | ||
| DEBUG_BUILD && logger.log(`Could not extract cookies from header ${cookieHeader}`); | ||
| } | ||
| return [headers, cookies]; | ||
| } | ||
| /** | ||
| * Interceptor function for XHR requests | ||
| * | ||
| @@ -192,7 +192,9 @@ function _getResponseSizeFromHeaders(headers?: Record<string, string>): number | | ||
| function _parseCookieString(cookieString: string): Record<string, string> { | ||
| return cookieString.split('; ').reduce((acc: Record<string, string>, cookie: string) => { | ||
| const [key, value] = cookie.split('='); | ||
| acc[key] = value; | ||
| if (key && value) { | ||
| acc[key] = value; | ||
| } | ||
| return acc; | ||
| }, {}); | ||
| } | ||
| @@ -228,7 +230,9 @@ function _getXHRResponseHeaders(xhr: XMLHttpRequest): Record<string, string> { | ||
| return headers.split('\r\n').reduce((acc: Record<string, string>, line: string) => { | ||
| const [key, value] = line.split(': '); | ||
| acc[key] = value; | ||
| if (key && value) { | ||
| acc[key] = value; | ||
| } | ||
| return acc; | ||
| }, {}); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
Check warning
Code scanning / CodeQL
Indirect uncontrolled command line