-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
911b3f0
ref: Enable `noUncheckedIndexedAccess ` TS config
mydea 11d55ad
fix remix
mydea 255e0d5
try-fix-test?
mydea 2a518a7
ref: Fix ts version properly for tests
mydea 686a898
fix remix test
mydea e088a14
fix script path, oops
mydea 0ee08f7
oops, remove again
mydea e22cffd
fix prepack script
mydea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
dev-packages/node-integration-tests/scripts/use-ts-version.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../tsconfig.test.json", | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
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; | ||
}, {}); | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.