Andrew Branch and GitHub
856c7c5fdd
Allow {} to narrow in same special cases as unknown ( #50601 )
2022-09-02 09:47:27 -07:00
Anders Hejlsberg and GitHub
854d448e5c
in operator shouldn't narrow {} originating in unknown (#50610 )
...
* 'in' operator shouldn't narrow {} originating in unknown
* Add regression test
2022-09-02 09:30:17 -07:00
Oleksandr T and GitHub
bcf994996e
fix(50079): show deprecated on JSX attributes ( #50084 )
2022-09-01 16:59:29 -07:00
Andrew Branch and GitHub
5df09a514c
Use bidirectional comparability in narrowing ( #50592 )
...
* Use bidirectional comparability (aka comparability) in narrowing
* Rename test, check other CFA branch, test without strictNullChecks
2022-09-01 14:26:48 -07:00
Anders Hejlsberg and GitHub
6db2c882f3
{} & null and {} & undefined should always be never ( #50553 )
...
* {} & null and {} & undefined should be never in non-strictNullChecks mode
* Add tests
* Address code review feedback
* Accept new baselines
2022-09-01 12:37:13 -07:00
Mateusz Burzyński and GitHub
238c341701
Defer distributing index over generic object types ( #50540 )
...
* Defer distributing index over generic object types
* Only check if the index type should be deferred for intersection types
* Add an additional test case
2022-09-01 07:28:13 -07:00
Sheetal Nandi and GitHub
298309271b
Do not canonicalize the file names when getting absolute paths during nodenext resolution ( #50557 )
...
* Add test to show how scope messes with casing
* Do not canonicalize the file names when getting absolute paths
Fixes #50544
* Unnecessary exports
* Add test for self referencing package
* Fix self reference package with casing
2022-09-01 06:48:41 -07:00
Oleksandr T and GitHub
a9797d218d
fix(50340): typeof ... === "undefined" check on discriminated union of undefined and object type doesn't narrow correctly ( #50344 )
...
* fix(50340): narrow type by discriminant in typeof
* add additional test cases
2022-08-31 15:00:50 -07:00
Anders Hejlsberg and GitHub
43f8ae6df4
Only normalize intersections that include {} ( #50535 )
...
* Only normalize intersections that include {}
* Accept new baselines
2022-08-31 14:36:03 -07:00
Sheetal Nandi and GitHub
d293e723a2
Rename API to importPlugin ( #50554 )
...
* Rename API to importPlugin
* Make it internal too
2022-08-31 14:21:56 -07:00
Wesley Wigham and GitHub
488d0eebd0
Retain name and propertyName in declaration emit copies of binding patterns if property name is a keyword ( #50537 )
...
* Retain name and propertyName in declaration emit copies of binding patterns if property name is a keyword
* Accept baselines
* Remove out of date file
2022-08-30 09:03:02 -07:00
Anders Hejlsberg and GitHub
6d170b490d
Handle intersections in isGenericTypeWithoutNullableConstraint ( #50497 )
...
* Handle intersections in isGenericTypeWithoutNullableConstraint
* Add regression test
2022-08-29 09:24:13 -07:00
Alex Hsu and GitHub
ed6889cd5b
LEGO: Merge pull request 50506
...
LEGO: Merge pull request 50506
2022-08-29 03:47:42 -07:00
Alex Hsu and GitHub
29cbfe9a25
LEGO: Merge pull request 50493
...
LEGO: Merge pull request 50493
2022-08-28 03:32:25 -07:00
Alex Hsu and GitHub
6faa291b45
LEGO: Merge pull request 50484
...
LEGO: Merge pull request 50484
2022-08-27 03:51:23 -07:00
Joost Koehoorn and GitHub
71b2ba6111
Reuse computed type of condition expressions ( #49881 )
2022-08-27 01:40:13 -07:00
Oleksandr T and GitHub
4579245f36
fix(50427): allow convert function expressions ( #50430 )
2022-08-26 15:43:19 -07:00
Oleksandr T and GitHub
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
Ryan Cavanaugh and GitHub
3557092b14
Rephrase error message to be 100% technically correct ( #50471 )
2022-08-26 14:22:49 -07:00
71d1911503
add unknown to DateTimeFormatTypes ( #50402 )
...
* add unknown to DateTimeFormatTypes
* move unknown to es2019.intl instead
* Accepted baselines.
Co-authored-by: long.ho <long.ho@cloudkitchens.com >
2022-08-26 13:02:44 -07:00
Anders Hejlsberg and GitHub
6e8337ef70
Optimize substitution types ( #50397 )
...
* Optimize substitution type infrastructure
* Accept new baselines
* Preserve instantiated substitution types for type variables
* Restrictive type parameters should have no constraint
* Fix issues from top100 test run
* Accept new baselines
2022-08-26 12:06:06 -07:00
Jake Bailey and GitHub
226dd0b7bf
Fix typechecking related lints that changed post 4.8, update LKG to 4.8.2 ( #50472 )
2022-08-26 11:41:45 -07:00
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 and GitHub
38076df346
Fix auto import crash due to difference in paths handling ( #50419 )
2022-08-25 13:02:48 -07:00
Oleksandr T and GitHub
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
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 and GitHub
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
Daniel Rosenwasser and GitHub
fb717df6bf
Discard union types before considering weak type checks on unit-like types ( #50423 )
...
* Only check isUnitType when dealing with non-unions.
* Add test case.
* Accepted baselines.
2022-08-24 11:39:00 -07:00
Sheetal Nandi and GitHub
b9a5bbc9af
Syntax operations also need to ensure project is present for the open script infos since update could be pending to make sure open script info has project ( #50418 )
...
Also convert one relevant test case to baseline
Fixes #50131
2022-08-24 10:28:23 -07:00
Oleksandr T and GitHub
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 and GitHub
4605d89064
Use a mapped type to enforce type-safety on forEachChild. ( #50409 )
2022-08-22 17:30:44 -07:00
Jake Bailey and GitHub
6362fb2dce
Replace eslint rulesdir with eslint-plugin-local, convert eslint rules to JS ( #50380 )
2022-08-22 13:46:03 -07:00
Ron Buckton and GitHub
aaa4f9d9ff
Make canHaveModifiers/Decorators public ( #50399 )
2022-08-22 15:01:17 -04:00
Daniel Rosenwasser and GitHub
76357ba802
Swap forEachChild to use a table of functions instead of a switch statement. ( #50225 )
...
* Swap `forEachChild` to use an array of functions instead of a `switch` statement.
* Let's see if 'new' changes anything.
* Co-locate each assignment into `forEachChildTable`.
* Try `push`ing undefined to create a packed Array.
* Try using an unconditional no-op function.
* `forEach` -> `forEachChildIn`
* Remove the optional chain if we are pre-filling with no-ops.
* Grab function directly to avoid possible `.call` overhead from downlevel emit.
* Swap to object literal.
* Lints and formatting.
2022-08-21 17:48:45 -07:00
Alex Hsu and GitHub
38e91fb120
LEGO: Merge pull request 50389
...
LEGO: Merge pull request 50389
2022-08-21 03:07:27 -07:00
Ron Buckton and GitHub
284837d66b
Fixes for decorators property deprecations ( #50343 )
...
* Change type of deprecated 'decorators' property
* fix 'Invalid Arguments' error for create/update constructor in factory
* Update deprecation comments
* Make 'decorators' optional and 'undefined'
* Rename '_decorators' to 'illegalDecorators'
* Update baselines
2022-08-19 14:27:26 -04:00
Oleksandr T and GitHub
5969ae9ef7
fix(50075): do not strip undefined from the function class properties ( #50169 )
2022-08-19 09:34:42 -07:00
Wesley Wigham and GitHub
05d7d6bb12
Unify default import resolution across specifier target codepaths ( #49814 )
...
* Unify default import resolution across specifier target codepaths
* Use differing type aliases, per request
2022-08-19 02:25:41 -07:00
Sheetal Nandi and GitHub
1f0f7c8246
If resolvedFileName differs with realPath only in casing use the resolvedFileName before realpath so that errors can be reported with forceConsistentCasingInFileNames ( #50364 )
...
* Add tests when realpath supresses the casing error
* Fix when real path results in value that differs only in case
Fixes #49470
* Comment
2022-08-18 14:51:46 -07:00
Kyℓe Hensel and GitHub
ea36fb3d5f
mark Intl.LocalesArgument as readonly ( #50135 )
2022-08-18 14:38:41 -07:00
Ron Buckton and GitHub
1592210673
Add a jump-table for visitEachChild ( #50266 )
...
* Add a jump-table for visitEachChild
* Name each visitor function for better stack traces
* Fix node tests and some minor cleanup
2022-08-18 15:03:17 -04:00
Daniel Rosenwasser and GitHub
7bafbeae90
Add fourslash function for validating syntactic classification ( #50362 )
2022-08-18 11:28:08 -07:00
Alex Hsu and GitHub
42165a183a
LEGO: Merge pull request 50353
...
LEGO: Merge pull request 50353
2022-08-18 03:12:12 -07:00
Alex Hsu and GitHub
15f7b6f687
LEGO: Merge pull request 50337
...
LEGO: Merge pull request 50337
2022-08-17 03:02:07 -07:00
3b80ddca21
fix first match in RegExpMatchArray being possibly undefined when noUncheckedIndexedAccess is enabled ( #49682 )
...
* fix first match in `RegExpMatchArray` being possibly undefined when `noUncheckedIndexedAccess` is enabled
* fix tests
* add test
Co-authored-by: DetachHead <detachhead@users.noreply.github.com >
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com >
2022-08-16 10:12:12 -07:00
Andrew Branch and GitHub
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
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
Andrew Branch and GitHub
4e33e0eb6c
Make literal types not comparable to weak object types without property overlap ( #49865 )
2022-08-15 17:10:11 -07:00
Andrew Branch and GitHub
64ee1e88e0
Strip literal freshness of contextually typed literals ( #49884 )
...
* Strip literal freshness of contextually typed literals
* Add more tests
2022-08-15 17:04:09 -07:00
Sheetal Nandi and GitHub
9c1baeede6
On windows handle the long paths in realpathSync.native ( #50306 )
...
Fixes #49470
2022-08-15 16:57:47 -07:00