Oleksandr T
08b91f6b82
fix(50717): tsc crashes when it sees a JSDoc tag inside an @override annotation ( #50724 )
2022-09-13 12:51:17 -07:00
Ron Buckton
a4cabe725b
Support for auto-accessor fields from the Stage 3 Decorators proposal ( #49705 )
...
* Support for auto-accessor fields
* Add tests, ensure accessors are initialized in ctor
* classFields cleanup and PR feedback
2022-09-12 15:12:11 -04:00
Jake Bailey
eb40134373
Don't leave space for property access on non-integer literals ( #50703 )
2022-09-09 14:36:39 -07:00
Jake Bailey
1a1c271675
Don't remove space before dot if in property access on numeric literal ( #50695 )
...
* Add failing test
* Don't remove space before dot if in property access on numeric literal
2022-09-08 19:08:51 -07:00
Oleksandr T
bcf994996e
fix(50079): show deprecated on JSX attributes ( #50084 )
2022-09-01 16:59:29 -07:00
Oleksandr T
4579245f36
fix(50427): allow convert function expressions ( #50430 )
2022-08-26 15:43:19 -07:00
Oleksandr T
bb3a7aec11
fix(50415): Language server debug failure - Did not expect GetAccessor to have an Identifier in its trivia ( #50470 )
...
* fix(50415): clone props for get/set accessors
* add additional tests
* create helpers to create name, body, modifiers, typeName
* cleanup
2022-08-26 14:33:23 -07:00
Oleksandr T
164dddc48e
feat(7481): Operator to ensure an expression is contextually typed by, and satisfies, some type ( #46827 )
...
* feat(7481): add explicit type compatibility check with 'satisfies' expression
* Add failing test for lack of intersectioned contextual type
* Implement the behavior
* Add test corresponding to the 'if'
* Add test based on defined scenarios
* remove isExpression in favor of using type casting
* move tests from compiler to conformance folder
* update baseline
* add missing contextFlags argument
* use asserted type
* accept baseline
Co-authored-by: Ryan Cavanaugh <ryanca@microsoft.com>
2022-08-26 10:05:52 -07:00
Andrew Branch
38076df346
Fix auto import crash due to difference in paths handling ( #50419 )
2022-08-25 13:02:48 -07:00
Oleksandr T
12eb519b3f
fix(50435): Duplicate seeming Code Actions for convert const to let ( #50442 )
...
* fix(50435): omit fix all in constToLet QF
* add FixAll action
2022-08-25 13:01:46 -07:00
Danay
a08b045d2b
Jsdoc property description ( #50269 )
...
* jsdocPropertyDescription
* jsdocPropertyDescription
* jsdocPropertyDescription
* Fixes #47933
* added additional test
* added additional example
* fixed bug
* changed function to only grab the literal type
* added additional condition for literals and symbols
* added additional test cases
* Update src/services/symbolDisplay.ts
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
* addressed PR review
* addressed new PR review
Co-authored-by: Danay Fernandez Alfonso <t-danayf@microsoft.com>
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
2022-08-25 11:57:32 -07:00
Oleksandr T
8d7ad8c3ae
fix(50375): Errors for missing enum-named properties should attempt to preserve names ( #50382 )
...
* fix(50375): preserve enum-named properties
* add AllowComputedPropertyEnums option
* use bit shifting
* rename AllowComputedPropertyEnum -> WriteComputedProps
* mark WriteComputedProps as internal
* mark symbolToNode as internal
2022-08-24 11:54:44 -07:00
Oleksandr T
44ce3cff70
fix(50224): Intellisense for strings within a type's Union doesn't work properly for JSX ( #50231 )
...
* fix(50224): show string literal completions in JsxAttributeInitializer
* add feedback changes
2022-08-23 14:59:10 -07:00
Daniel Rosenwasser
7bafbeae90
Add fourslash function for validating syntactic classification ( #50362 )
2022-08-18 11:28:08 -07:00
Andrew Branch
330e33cdda
Ignore related info in diagnostic deduplication ( #50309 )
...
* Ignore related info in diagnostic deduplication
* Add another test
2022-08-16 09:28:59 -07:00
Babak K. Shandiz
f24f74eb89
🔨 Fix missing "Implement interface" code fix for mapped types with implicit keyof T in their definition ( #49999 )
...
* ⚗️ Add test to verify code fix works when implementing a mapped type with indirect keyof
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
* 🔨 Add property as implementation for symbols that has no declaration
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts
index 94b64e57..a4c11fd5 100644
--- a/src/services/codefixes/helpers.ts
+++ b/src/services/codefixes/helpers.ts
@@ -60,21 +60,19 @@ namespace ts.codefix {
isAmbient = false,
): void {
const declarations = symbol.getDeclarations();
- if (!(declarations && declarations.length)) {
- return undefined;
- }
+ const declaration = declarations ? declarations[0] : undefined;
const checker = context.program.getTypeChecker();
const scriptTarget = getEmitScriptTarget(context.program.getCompilerOptions());
- const declaration = declarations[0];
+ const kind = declaration?.kind ?? SyntaxKind.PropertySignature;
const name = getSynthesizedDeepClone(getNameOfDeclaration(declaration), /*includeTrivia*/ false) as PropertyName;
- const visibilityModifier = createVisibilityModifier(getEffectiveModifierFlags(declaration));
+ const visibilityModifier = createVisibilityModifier(declaration ? getEffectiveModifierFlags(declaration) : ModifierFlags.None);
const modifiers = visibilityModifier ? factory.createNodeArray([visibilityModifier]) : undefined;
const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
const optional = !!(symbol.flags & SymbolFlags.Optional);
const ambient = !!(enclosingDeclaration.flags & NodeFlags.Ambient) || isAmbient;
const quotePreference = getQuotePreference(sourceFile, preferences);
- switch (declaration.kind) {
+ switch (kind) {
case SyntaxKind.PropertySignature:
case SyntaxKind.PropertyDeclaration:
const flags = quotePreference === QuotePreference.Single ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : undefined;
@@ -88,13 +86,16 @@ namespace ts.codefix {
}
addClassElement(factory.createPropertyDeclaration(
modifiers,
- name,
+ declaration ? name : symbol.getName(),
optional && (preserveOptional & PreserveOptionalFlags.Property) ? factory.createToken(SyntaxKind.QuestionToken) : undefined,
typeNode,
/*initializer*/ undefined));
break;
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor: {
+ if (!declarations) {
+ break;
+ }
let typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
const allAccessors = getAllAccessorDeclarations(declarations, declaration as AccessorDeclaration);
const orderedAccessors = allAccessors.secondAccessor
@@ -138,6 +139,10 @@ namespace ts.codefix {
// If there is more than one overload but no implementation signature
// (eg: an abstract method or interface declaration), there is a 1-1
// correspondence of declarations and signatures.
+ if (!declarations) {
+ break;
+ }
+
const signatures = checker.getSignaturesOfType(type, SignatureKind.Call);
if (!some(signatures)) {
break;
* 🔨 Improve code readability
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts
index 2f5c8703ab..aea0206a8a 100644
--- a/src/services/codefixes/helpers.ts
+++ b/src/services/codefixes/helpers.ts
@@ -60,7 +60,7 @@ namespace ts.codefix {
isAmbient = false,
): void {
const declarations = symbol.getDeclarations();
- const declaration = declarations ? declarations[0] : undefined;
+ const declaration = declarations?.[0];
const checker = context.program.getTypeChecker();
const scriptTarget = getEmitScriptTarget(context.program.getCompilerOptions());
const kind = declaration?.kind ?? SyntaxKind.PropertySignature;
@@ -93,9 +93,7 @@ namespace ts.codefix {
break;
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor: {
- if (!declarations) {
- break;
- }
+ Debug.assertIsDefined(declarations);
let typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
const allAccessors = getAllAccessorDeclarations(declarations, declaration as AccessorDeclaration);
const orderedAccessors = allAccessors.secondAccessor
@@ -139,10 +137,7 @@ namespace ts.codefix {
// If there is more than one overload but no implementation signature
// (eg: an abstract method or interface declaration), there is a 1-1
// correspondence of declarations and signatures.
- if (!declarations) {
- break;
- }
-
+ Debug.assertIsDefined(declarations);
const signatures = type.isUnion() ? flatMap(type.types, t => t.getCallSignatures()) : type.getCallSignatures();
if (!some(signatures)) {
break;
* 📜 Add comment regarding mapped type children's missing declaration
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
Co-authored-by: Andrew Branch <andrew@wheream.io>
2022-08-16 09:27:29 -07:00
Oleksandr T
61d8a8d7f3
fix(49629): fix crash in find-all-refs when using module.exports/export= with arrays/primitives ( #50291 )
2022-08-15 15:14:26 -07:00
Andrew Branch
bc52ff6f4b
Make React import fix not block component import fix ( #50307 )
...
* Stop React import fix from blocking component import fixes
* Add additional promote-type-only test
2022-08-15 13:13:41 -07:00
Oleksandr T
f70cb769ef
feat(49928): Provide quick fix for a missing callback function ( #49930 )
...
* feat(49928): provide quick fix for a missing callback function
* remove addFunctionDeclarationFromSignature. fix formatting
* add tests
2022-08-09 15:28:03 -07:00
Oleksandr T
19e2a310c0
feat(49834): Suggestion: filter enum member ids from their own jsdocs ( #49843 )
...
* feat(49834): omit self-referenced enum declaration in JsDoc
* change code style
2022-08-09 15:02:45 -07:00
Oleksandr T
a44354af7c
fix(50188): omit QF on function arguments ( #50189 )
2022-08-04 17:52:09 -07:00
Andrew Branch
c82c9a9744
Fix bugs in module specifier generation with paths/typesVersions ( #49792 )
...
* Write a test and a huge comment
* Finish fixing everything
* Clean up comment
* Remove obsolete comment
* Fix comment trailing off
* Optimize to hit the file system much less
2022-08-03 13:58:15 -07:00
Oleksandr T
59c91f6ce9
fix(50077): skip convertOverloadListToSingleSignature refactoring if position is in function body ( #50093 )
2022-08-03 13:56:42 -07:00
Andrew Branch
b7355e30af
Fix trailing formatting edit when range ends mid-token ( #50082 )
2022-07-28 12:11:22 -07:00
Oleksandr T
94bb950008
feat(49358): use filename based on exported name ( #49875 )
2022-07-27 15:41:31 -07:00
Josh Goldberg
ebd42abf95
Account for type parameters in missing function codefix ( #49727 )
...
* Account for type parameters in missing function codefix
* Apply suggestions from code review
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* WIP
* Synthesize new type parameters instead of deep unions and intersections
* Pass along type parameter constraints
* E.T. phone home
* Clean up comments just a bit
* Only widen the instance type sometimes
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-07-26 15:22:19 -07:00
Oleksandr T
bcd22b47d2
fix(50048): remove token name from id ( #50051 )
2022-07-26 01:13:04 -07:00
Jake Bailey
966e732ed4
Remove uses of visitNodes and visitNode in visitEachChild ( #49992 )
2022-07-22 19:35:39 -07:00
Oleksandr T
455ea9b41f
fix(49964): handle auto-import dependencies/omit duplicate constraints ( #50004 )
2022-07-22 11:01:43 -07:00
Armando Aguirre
7b764164ed
Fixed closing JSDoc when adding multiple blocks ( #49888 )
...
* Fixed closing JSDoc when adding multiple blocks
* Fixed linting errors
* Refactored to use `some`
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Removed empty lines
Co-authored-by: Armando Aguirre <araguir@microsoft.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-07-21 13:16:40 -07:00
Oleksandr T
f6ac10958f
fix(49704): Code folding not working in file with simple syntax error ( #49743 )
...
* fix(49704): parse type arguments in super call expression
* omit duplicate errors
2022-07-19 16:26:56 -07:00
Oleksandr T
5a53e9bb5e
fix(49838): "Extract function" refactoring action is disabled for a wrong reason ( #49840 )
...
* fix(49838): allow extracting functions with a break statement inside loop context
* remove useless flag
* add more tests
2022-07-19 13:06:45 -07:00
Oleksandr T
3863cc4a20
feat(49786): show completions in expression with type arguments ( #49810 )
2022-07-18 14:55:15 -07:00
Oleksandr T
91f7cfc501
fix(49392): show optional class methods with enabled strict option ( #49768 )
2022-07-18 14:49:13 -07:00
Babak K. Shandiz
8e6e87fea6
🐛 Fix smart selection of propery signatures having JSDoc comments ( #49804 )
...
* 🐛 Avoid grouping JSDoc nodes of propery signatures with others in smart selection
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
* ⚗️ Add test case for JSDoc smart selection (#39618 )
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
* ⚗️ Add test baseline for JSDoc smart selection (#39618 )
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
* 🐛 Fix skipping SyntaxList first child's JSDoc in smart selection
Signed-off-by: GitHub <noreply@github.com>
* ⚗️ Add tests to ensure not skipping first SyntaxList child's JSDoc
Signed-off-by: GitHub <noreply@github.com>
* 🔨 Exclude JSDoc token from tokens pivoting property signature
Signed-off-by: GitHub <noreply@github.com>
* ⚗️ Update test case to also include modifier
Signed-off-by: GitHub <noreply@github.com>
* ⚗️ Update test case reference baseline
Signed-off-by: GitHub <noreply@github.com>
2022-07-12 09:04:21 -07:00
Andrew Branch
9dde56c6fc
Add path completions for package.json exports with wildcards ( #49644 )
...
* Support path completions for exports wildcards
* Break up results by directory
* Share code between typesVersions and exports processing
* Revert completion kind change
* Add kinds to tests
* Update existing test
* Support nested conditions, improve recursive globbing
2022-07-07 12:26:18 -07:00
AlCalzone
f6684be95e
fix: correct name length criterion for spelling fixes ( #49575 )
...
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
2022-07-07 09:08:37 -07:00
Oleksandr T
7584e6aad6
fix(49642): resolve JsDoc comments/tags if accessors exist in symbol declarations ( #49654 )
2022-07-06 15:41:50 -07:00
Oleksandr T
cdc1996e87
fix(49426): Object method snippet completions incorrectly add this parameters ( #49757 )
...
* fix(49426): omit this parameter
* add OmitThisParameter to TypeFormatFlags
* change flag value
2022-07-05 11:46:19 -07:00
Wesley Wigham
52f4055174
For missing constraint quickfix insert position, Use node name end rather than related span end ( #49673 )
2022-06-29 11:46:42 -07:00
Nathan Shively-Sanders
cba184f69b
Demote priority of JS completions ( #49716 )
...
* Demote priority of JS completions
Fixes #48498
Unchecked JS files gather identifier-based completions. Currently, this search
happens instead of `getCompletionEntriesFromSymbols` for TS/checked JS
files. However, identifier-based completions are much lower quality and
can be ignored by some editors.
Identifier-based completions should be gathered last, after gathering
other completions. That's what this PR does.
* Invert isUncheckedFile to avoid double negative
* dedupe calls to getCompletionEntriesFromSymbols
* Stop re-creating list of entry names
* more deduping + fix lint
2022-06-29 11:05:50 -07:00
bentongxyz
b24b6a1125
fixes #49491 ( #49493 )
2022-06-22 13:25:01 -07:00
Oleksandr T
74d76e93b3
fix(49546): create computed property name for symbol props ( #49554 )
2022-06-20 13:46:47 -07:00
Oleksandr T
c01afb5ef3
fix(49548): show completions after keywords in block ( #49600 )
2022-06-20 12:52:28 -07:00
Andrew Branch
7e7c53961a
Add TS Server option to exclude files from auto-imports ( #49578 )
...
* Basic functionality
* Add tests
* Add test for ambient modules
* Add to protocol
2022-06-17 14:39:51 -07:00
Gabriela Araujo Britto
86d5040031
Fix renaming of node_modules ( #49568 )
...
* add bug repro test
* add test and start fix implementation
* adjust for useAlias preference
* fix existing renaming test
* refactor to get rid of options
* fix named bindings & other imports cases
* fix eslint error
* address cr comments
* hopefully actually fix eslint
* clean up stale baseline
* make API change non-breaking
* add/fix comments
2022-06-16 17:01:44 -07:00
Oleksandr T
f83ce9bd9c
fix(49566): Implicit this.property completions not returned while writing property ( #49574 )
...
* fix(49566): show this.prop completions in class scoped property declaration
* remove duplicate default value
2022-06-16 12:43:50 -07:00
Oleksandr T
180bc4cbea
feat(49385): forbid inlay hints for some kind of initialized declarations ( #49412 )
...
.
2022-06-15 15:34:57 -07:00
Wesley Wigham
ba38fe1df2
Expand constraint suggestion related span and add quick fix ( #49481 )
...
* Expand constraint suggestion related span and add quick fix
* Remove circular constraint suggestions
* Add error code
* Style feedback and new error code in quickfix
2022-06-15 10:35:51 -07:00
Oleksandr T
806a710470
fix(49478): add return type to method signature ( #49482 )
2022-06-10 14:14:36 -07:00