https://github.com/Microsoft/TypeScript

sort by:
Revision Author Date Message Commit Date
cad0114 prototype feature 29 August 2022, 21:08:35 UTC
aaa4f9d Make canHaveModifiers/Decorators public (#50399) 22 August 2022, 19:01:17 UTC
3f7ff15 Update package-lock.json 22 August 2022, 06:08:09 UTC
76357ba 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. 22 August 2022, 00:48:45 UTC
38e91fb LEGO: Merge pull request 50389 LEGO: Merge pull request 50389 21 August 2022, 10:07:27 UTC
7cab345 Update package-lock.json 21 August 2022, 06:07:14 UTC
50041bd Update package-lock.json 20 August 2022, 06:06:43 UTC
6cbb39b Re-caret dependencies so deps like eslint continue to be bumped (#50368) 19 August 2022, 19:58:54 UTC
284837d 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 19 August 2022, 18:27:26 UTC
ef88fbb Remove some unused deps and dead code (#50367) 19 August 2022, 16:42:14 UTC
5969ae9 fix(50075): do not strip undefined from the function class properties (#50169) 19 August 2022, 16:34:42 UTC
05d7d6b Unify default import resolution across specifier target codepaths (#49814) * Unify default import resolution across specifier target codepaths * Use differing type aliases, per request 19 August 2022, 09:25:41 UTC
cb63d46 Update package-lock.json 19 August 2022, 06:07:20 UTC
1f0f7c8 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 18 August 2022, 21:51:46 UTC
ea36fb3 mark Intl.LocalesArgument as readonly (#50135) 18 August 2022, 21:38:41 UTC
1592210 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 18 August 2022, 19:03:17 UTC
7bafbea Add fourslash function for validating syntactic classification (#50362) 18 August 2022, 18:28:08 UTC
df25b77 Run eslint at root, rather than on src and scripts individually (#50327) 18 August 2022, 18:24:10 UTC
42165a1 LEGO: Merge pull request 50353 LEGO: Merge pull request 50353 18 August 2022, 10:12:12 UTC
66d8b95 Ensure all scripts are checked, fix errors (#50326) 17 August 2022, 23:42:50 UTC
15f7b6f LEGO: Merge pull request 50337 LEGO: Merge pull request 50337 17 August 2022, 10:02:07 UTC
745da27 Update package-lock.json 17 August 2022, 06:06:59 UTC
3b80ddc 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> 16 August 2022, 17:12:12 UTC
330e33c Ignore related info in diagnostic deduplication (#50309) * Ignore related info in diagnostic deduplication * Add another test 16 August 2022, 16:28:59 UTC
f24f74e 🔨 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> 16 August 2022, 16:27:29 UTC
90fa1c7 Update baseline after out-of-order merge (#50320) 16 August 2022, 15:54:55 UTC
9767f51 Update package-lock.json 16 August 2022, 06:06:30 UTC
4e33e0e Make literal types not comparable to weak object types without property overlap (#49865) 16 August 2022, 00:10:11 UTC
64ee1e8 Strip literal freshness of contextually typed literals (#49884) * Strip literal freshness of contextually typed literals * Add more tests 16 August 2022, 00:04:09 UTC
9c1baee On windows handle the long paths in realpathSync.native (#50306) Fixes #49470 15 August 2022, 23:57:47 UTC
e989d84 Forward intersectionState flag when comparing indexed access constraints (#50261) 15 August 2022, 23:10:32 UTC
8a873de fix(49149): remove unneeded array overload to Object.freeze (#50029) * fix(49149): remove unneeded array overload to Object.freeze * chore: commit baseline changes Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Co-authored-by: Andrew Branch <andrew@wheream.io> 15 August 2022, 23:10:02 UTC
61d8a8d fix(49629): fix crash in find-all-refs when using module.exports/export= with arrays/primitives (#50291) 15 August 2022, 22:14:26 UTC
bc52ff6 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 15 August 2022, 20:13:41 UTC
fd3c46b Fix export = error message to not have redundant language (#50308) 15 August 2022, 20:13:33 UTC
9f7c0cb Run ESLint over our JS files, fix all lints (#50172) 15 August 2022, 15:42:26 UTC
03b12a6 LEGO: Merge pull request 50298 LEGO: Merge pull request 50298 14 August 2022, 10:10:53 UTC
656d6a5 Update package-lock.json 14 August 2022, 06:06:50 UTC
7f5600e LEGO: Merge pull request 50295 LEGO: Merge pull request 50295 13 August 2022, 12:07:02 UTC
adf26ff Revert "Fixed an issue with contextual type for intersection properties (#48668)" (#50279) This reverts commit 9236e39374c0ec9a1e3f9894af4fb9eb34ba0021. 12 August 2022, 17:24:50 UTC
8783da8 Update package-lock.json 12 August 2022, 06:06:46 UTC
b19741c Report aggregate statistics for solution as well as some solution perf numbers (#50267) * Report aggregate statistics for solution as well as some solution perf numbers This change under --extendedDiagnostics aggregates the diagnostics from all projects built and reports it at the end. Apart from that it also outputs some measurements for work that happens in tsc --build like finding if projects are uptodate etc. Also removes unnecessary node count per suggestion * Apply suggestions from code review Co-authored-by: Ron Buckton <ron.buckton@microsoft.com> * Fix condition * Remove extra time Co-authored-by: Ron Buckton <ron.buckton@microsoft.com> 11 August 2022, 20:20:48 UTC
075ee3d refactor: follow gh-50257 JSX.IntrinsicClassAttributes logic (#50271) 11 August 2022, 16:32:31 UTC
9189e42 Update package-lock.json 11 August 2022, 06:06:47 UTC
e2fbe19 fix: produceLKG does not work on Windows (#50140) 11 August 2022, 03:12:17 UTC
924c68c use cache for program creation on watch mode. (#49958) 10 August 2022, 23:56:54 UTC
90cfbae Make build info tolerant to json errors (#50265) * Make build info tolerant to json errors Fixes #49754 * Fix incorrect code 10 August 2022, 23:44:35 UTC
8a24fe7 Fix up code so we don't crash when TS itself is emitted with let/const (#50151) 10 August 2022, 20:38:38 UTC
b56483f Remove shims project (#50049) 10 August 2022, 18:49:59 UTC
7f1dc78 Simplify normalizeSlashes (#50154) 10 August 2022, 18:20:00 UTC
5fbf3b0 Don't treat object properties as potential JS contructors without JSDoc class tag (#49735) 10 August 2022, 18:19:19 UTC
382f0c3 fix: crashes when JSX.IntrinsicClassAttributes is an alias type close GH-50254 (#50257) 10 August 2022, 17:41:12 UTC
3c3909b update baseline (#50252) 10 August 2022, 08:52:59 UTC
5f64ae8 Update package-lock.json 10 August 2022, 06:07:48 UTC
35c6fbf JSDoc @type tag optional parameters (#48132) * JSDoc @type tag optional parameters * Don't repeat isInJSFile() condition * Exclude variable initializers * Add tests for class methods * Don't contextually type JS function declarations * Update Baselines and/or Applied Lint Fixes * Reword comment Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com> 10 August 2022, 00:03:30 UTC
2513a2d Use binary search in file system cache (#50163) * Use binary search in file system cache Previously, we were linear searching a linear number of times, resulting in too many `toLowerCaseFileName` calls on Windows. * Use SortedArray types for clarity * Use insertSorted after making it return a flat * Drop redundant undefined * Correct copy-paste error 09 August 2022, 23:47:07 UTC
af90e70 feat(49903): omit declare on type declarations (#49925) 09 August 2022, 23:38:42 UTC
b94b299 fix CFA for BindingElement. #49759 (#49836) * fix CFA for BindingElement. #49759 * fix Parameter * fix controlFlowBindingPatternOrder * fix bindParameterFlow * add tests * refactor * refactor * refactor 09 August 2022, 23:37:39 UTC
dd98c17 Merge multiple symbols even when re-exported (#49987) * Merge multiple symbols even when re-exported As far as I remember, the target of `mergeSymbol` needs to be a merged symbol, not a symbol with a mergeId that points to mergedSymbol. However, mergeSymbolTable didn't check for this. I can't remember if symbol tables may contain symbols-with-mergeId. If they can, then mergeSymbolTable needs to call getMergedSymbol on the individual targets of the merge. That's what I did in this PR. * Call getMergeSymbol eagerly On the source, not target, of mergeSymbolTable's contents 09 August 2022, 23:36:53 UTC
abc2a35 Fix System module `export import =` (#49788) * Add more SystemJS test case * Fix System module `export import =` * Update test case 09 August 2022, 23:31:02 UTC
e5b400c Fix misleading Date constructor documentation (addresses #49350) (#49649) * Update month parameter to monthIndex and add docs for Date constructor Signed-off-by: jmorrison152 <jmorrison152@bloomberg.net> * Add baseline changes Signed-off-by: jmorrison152 <jmorrison152@bloomberg.net> * Fix misleading Date constructor documentation (addresses #49350) (#73) * Update month parameter to monthIndex and add docs for Date constructor Signed-off-by: jmorrison152 <jmorrison152@bloomberg.net> * Add baseline changes Signed-off-by: jmorrison152 <jmorrison152@bloomberg.net> * Update baselines 09 August 2022, 23:21:56 UTC
f70cb76 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 09 August 2022, 22:28:03 UTC
a123fc5 feat(lib/es2015): Add typed overloads to `Reflect` (#35608) Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> 09 August 2022, 22:05:33 UTC
19e2a31 feat(49834): Suggestion: filter enum member ids from their own jsdocs (#49843) * feat(49834): omit self-referenced enum declaration in JsDoc * change code style 09 August 2022, 22:02:45 UTC
6aa9b87 Bump version to 4.9. (#50239) 09 August 2022, 20:33:52 UTC
6d163dc Update package-lock.json 09 August 2022, 06:06:46 UTC
0e17dc7 Fixed a false positive related to binding patterns and spread expressions (#49684) * Fixed a false positive related to binding patterns and spread expressions * Improve ancestor lookup when checking if an expression is spread into an object * Fixed ancestor lookup for more node types * Remove equality check for contextual types * Reformat code * Use `isWithinSpreadAssignment` flag + `objectsWithinSpread` cache instead of ancestor traversal * Revert "Use `isWithinSpreadAssignment` flag + `objectsWithinSpread` cache instead of ancestor traversal" This reverts commit be387e3bbf8a5cce2bc4c31fd77b061ea6cf8e0b. * Expand on the existing comment 09 August 2022, 00:01:50 UTC
71e8529 LEGO: Merge pull request 50219 LEGO: Merge pull request 50219 08 August 2022, 10:00:51 UTC
4a98087 Update package-lock.json 08 August 2022, 06:06:51 UTC
3630994 LEGO: Merge pull request 50212 LEGO: Merge pull request 50212 07 August 2022, 11:59:36 UTC
7e42591 Update package-lock.json 07 August 2022, 06:06:32 UTC
96fe039 Update package-lock.json 06 August 2022, 06:08:54 UTC
bdb8514 Fix contextual typing on yield and return expressions in generator function (#49736) * add tests and initial fix * fix contextual return type in generator funcs * fix return statement contextual typing * filter using getiterationtypeofgeneratorfunctionreturntype * update baselines 05 August 2022, 18:24:43 UTC
5c1abd3 Update package-lock.json 05 August 2022, 06:06:36 UTC
a44354a fix(50188): omit QF on function arguments (#50189) 05 August 2022, 00:52:09 UTC
7afd14f Update error messages for CJS imports resolving to ES modules (#50088) * Update error messages for CJS imports resolving to ES modules * Update error message * Use package scope from source file * Update baselines * Issue error for JSX/TSX files * Switch from related info to message chain 04 August 2022, 23:58:13 UTC
b1176ce LEGO: Merge pull request 50179 LEGO: Merge pull request 50179 04 August 2022, 10:16:11 UTC
9499b6e Update package-lock.json 04 August 2022, 06:06:34 UTC
6bbe6d6 Fix return value and error reporting for getIterationTypesOfMethod (#50146) 03 August 2022, 23:07:29 UTC
bc7786b Ensure that file watcher is closed only once for affected file locations that share watcher because of different names but same real path (#50150) * Add test where clearing affected files watcher that also is shared by real path causes Debug failure * Ensure that file watcher is closed only once for affected file locations that share watcher because of different names but same real path * Lift up package json map 03 August 2022, 22:39:07 UTC
d6d2643 Add rule to auto-paren optional chain in normal prop or element access (#50156) 03 August 2022, 21:17:26 UTC
c82c9a9 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 03 August 2022, 20:58:15 UTC
59c91f6 fix(50077): skip convertOverloadListToSingleSignature refactoring if position is in function body (#50093) 03 August 2022, 20:56:42 UTC
a3a5e00 Downgrade es5-ext via overrides (#50061) 03 August 2022, 17:47:30 UTC
867512c Update package-lock.json 03 August 2022, 06:06:42 UTC
697935d Restore ordering of operations involving type parameters and unions (#50116) 03 August 2022, 04:32:41 UTC
040c121 Better typings for Promise.resolve(), like #31117 (#33074) * Better typings for Promise.resolve(), like #31117 * Add tests * Update to Awaited<T> * Fix issue with Awaited affecting jQuery, additional tests Co-authored-by: Ron Buckton <ron.buckton@microsoft.com> 02 August 2022, 17:39:50 UTC
8493ea1 Update package-lock.json 02 August 2022, 06:07:51 UTC
c0072aa fix(49935): omit parentheses in the operand of the unary expression (#50111) 01 August 2022, 21:22:45 UTC
55f2c0c No synthetic Awaited for unconstrained type when not a type variable (#50100) 01 August 2022, 21:19:15 UTC
394f51a Fix implied formats, file watching, new source file creating during edits (#50098) * Add test where module resolution cache is not local and hence doesnt report errors in watch mode * Ensure module resolution cache is passed through in watch mode * Remove unnecessary setting of impliedFormat which should anyways be done as part of create source file * Add test for packge.json changing and modifying implied format * Distinguish between package.json watch and affecting file location watch * Pass in failed lookup and affected file locations for source file's implied format Also stop creating options if we already have them * Add diagnostic for explaining file's implied format if based on package.json * Watch implied format dependencies for modules and schedule update on change * For program if implied node format doesnt match create new source file. Handle implied node format in document registry Fixes #50086 * Modify tests to show package.json being watched irrespective of folder its in * Check file path if it can be watched before watching package.json file * Because we are watching package.json files and failed lookups its safe to invalidate package json entries instead of clearing them out everytime program is created * Remove todos * Fix the incorrect merge * Pickup PackageJsonInfo renames from #50088 * Rename 01 August 2022, 19:41:37 UTC
427d436 Improve import type support for commonjs exports (#49745) * Improve import type support for commonjs exports This PR makes getTypeFromImportTypeNode a little more like getExternalModuleMember: for JS files, it now uses both `getTypeOfSymbol` and `getExportsOfSymbol`, and uses whichever one returns a symbol. This allows using arbitrary properties of a CJS export= as types in JSDoc; previously a special case in the binder enabled only CJS export= where all properties were shorthand assignments. Fixes #49195 * Add js types/value test case * Improve binding of CJS property assignments 1. Bind property assignments same as shorthand property assignments in module.exports object literal assignments. 2. Bind all such assignments, even if the object literal contains non-property assignments. This is different from before, and it requires slightly smarter code to prefer aliases when checking CJS imports. * Remove new binder code Just include the original fix * revert missed type in binder 01 August 2022, 17:57:38 UTC
e1ceb2e Update package-lock.json 01 August 2022, 06:14:56 UTC
a66a1a6 LEGO: Merge pull request 50110 LEGO: Merge pull request 50110 31 July 2022, 09:53:01 UTC
4f8c740 Update package-lock.json 31 July 2022, 06:06:24 UTC
14fb0b0 LEGO: Merge pull request 50104 LEGO: Merge pull request 50104 30 July 2022, 10:47:04 UTC
e56942b Update package-lock.json 30 July 2022, 06:06:37 UTC
ae7d232 fix(49869): throw an error on optional binding pattern parameter in JavaScript (#50094) 29 July 2022, 23:05:34 UTC
88a1e3a Transform decorators that reference private names into a 'static {}' block (#50074) 29 July 2022, 19:29:48 UTC
5374fd9 Add an additional test for favoring the asserted type in type predicate narrowing (#50065) * Add an additional test for favoring the asserted type in type predicate narrowing * Add requested test cases 29 July 2022, 19:12:33 UTC
back to top