Skip to content

Add refactor convertToOptionalChainExpression #39135

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 49 commits into from
Jul 14, 2020
Merged
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
77a49c3
add convertOptionalChain
Jun 12, 2020
9cf07cf
cover more cases
Jun 16, 2020
80bf5d1
expose containsMatchingReference
Jun 17, 2020
4e64236
clean up performing edits
Jun 17, 2020
9a59e13
bound start position
Jun 17, 2020
6c1bccf
add tests
Jun 17, 2020
2a355e4
refactor and handle edge cases
Jun 17, 2020
3dac9c6
update tests
Jun 18, 2020
b403037
consider explicit requests for empty spans
Jun 18, 2020
1ae5500
update fourslash to use trigger reason
Jun 18, 2020
bf28673
add tests cases for trigger reason
Jun 18, 2020
fa3f9c8
fix errors
Jun 18, 2020
8794154
remove type assertion
Jun 18, 2020
3d8fed1
fix non ampersand chains
Jun 18, 2020
b5c833c
clean up some logic
Jun 18, 2020
796b2bf
add ternary case
Jun 20, 2020
37004b7
add diagnostic message
Jun 20, 2020
3584bae
resolve merge conflict
Jun 20, 2020
1b2e86b
Merge remote-tracking branch 'upstream/master' into refactorOptionalC…
Jun 22, 2020
afb0e44
add nullish check for ternary expressions
Jun 22, 2020
65ca81e
Update src/services/refactors/convertToOptionalChainExpression.ts
jessetrinity Jun 22, 2020
d9c34ff
Update src/services/refactors/convertToOptionalChainExpression.ts
jessetrinity Jun 22, 2020
c2b9924
Update tests/cases/fourslash/refactorConvertToOptionalChainExpression…
jessetrinity Jun 22, 2020
1d51dab
Update tests/cases/fourslash/refactorConvertToOptionalChainExpression…
jessetrinity Jun 22, 2020
adbd586
reformat and remove unused checks
Jun 22, 2020
fb6b831
allow any for ternary refactor
Jun 23, 2020
8184ecf
add tests
Jun 23, 2020
5ac29a0
add tests
Jun 23, 2020
a0708be
check return and variable statements
Jun 23, 2020
6810cea
use isMatchingReference instead of containsMatchingReference
Jun 23, 2020
5634a4c
allow partial selections
Jun 23, 2020
e6e54cb
fine tune selection ranges
Jun 24, 2020
77f47e7
recurse for call expressions
Jun 24, 2020
1ba5fd0
fix spellings
Jun 24, 2020
6095e95
add recursive cases
Jun 25, 2020
89c8c9d
remove isOrContainsMatchingReference
Jun 26, 2020
b20cd95
cleanup
Jun 26, 2020
15176b2
more refactoring
Jun 29, 2020
2de5e28
cleanup
Jun 29, 2020
4126a46
rename tests
Jun 29, 2020
8f65c02
address PR comments
Jul 1, 2020
d4f6f52
Merge remote-tracking branch 'upstream/master' into refactorOptionalC…
Jul 1, 2020
8aed315
check match syntactically
Jul 2, 2020
602075f
handle another call expression case
Jul 7, 2020
a4cc060
some renames
Jul 7, 2020
e89ae08
inline some checks
Jul 7, 2020
2cdb5e1
add test
Jul 7, 2020
fd64b14
address comments
Jul 13, 2020
01854bb
add refactorNotAvailableReason
Jul 13, 2020
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
Prev Previous commit
Next Next commit
Update src/services/refactors/convertToOptionalChainExpression.ts
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
  • Loading branch information
jessetrinity and sandersn authored Jun 22, 2020
commit 65ca81e6e373373b1fc5da9527e900d451cc2a07
6 changes: 3 additions & 3 deletions src/services/refactors/convertToOptionalChainExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ namespace ts.refactor.convertToOptionalChainExpression {
const { file, program } = context;
const span = getRefactorContextSpan(context);

if (span.length === 0 && !considerEmptySpans) return undefined;
const forEmptySpan = span.length === 0 && considerEmptySpans;
const forEmptySpan = span.length === 0;
if (forEmptySpan && !considerEmptySpans) return undefined;

const startToken = getTokenAtPosition(file, span.start);

Expand Down Expand Up @@ -127,4 +127,4 @@ namespace ts.refactor.convertToOptionalChainExpression {
changes.replaceNode(sourceFile, expression, factory.createBinaryExpression(convertPropertyAccessToOptionalChain(checker, fullPropertyAccess, until), factory.createToken(SyntaxKind.QuestionQuestionToken), expression.whenFalse));
}
}
}
}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy