Commit Graph

22521 Commits

Author SHA1 Message Date
Ron Buckton
2c08affa0d Merge pull request #39264 from microsoft/migrateMapsAndSets
Migrate maps and sets
2020-07-13 10:38:30 -07:00
Andrew Branch
583bd92bc4 Don’t create expando declarations on alias symbols (#39558)
* Don’t create expando declarations on alias symbols

* Update other baseline

* Fix brace nesting refactor mistake
2020-07-13 10:05:48 -07:00
Kenn Sarsaba
629dd6487b Fix typo (#39585) 2020-07-13 07:43:53 -07:00
Alexander T
31f75fed09 fix(types/mocha): change deprecated Mocha types (#39573) 2020-07-12 21:21:07 -07:00
Ron Buckton
87fd1827f2 Merge pull request #39537 from microsoft/fix/helpers/use-hasownproperty-call
fix(helpers): Use `hasOwnProperty.call`
2020-07-10 16:54:02 -07:00
Sheetal Nandi
8002473ea6 Add ClassExpression, FunctionExpression and ArrowFunction to check for cancellation token from classifier (#39557)
Fixes #35364
2020-07-10 13:39:09 -07:00
Sheetal Nandi
294fcb537c Handle typeAcquisition could be undefined (#39551)
Fixes #36834
2020-07-10 12:56:35 -07:00
Anders Hejlsberg
c335aad665 Remove object literal freshness in control flow based array types (#39518)
* Remove object literal freshness in control flow based array types

* Add regression test
2020-07-10 10:18:15 -07:00
Nathan Shively-Sanders
3b107fec3b Fix @param type parameter lookup (#39532)
Previously, getObjectTypeInstantiation had special-case code to look up
type parameters for `@param` as if they were in the parameter location.

This should occur in the main lookup loop of `getOuterTypeParameters`,
however. The current code only runs once, which is not sufficient, and
it also jumps to the parameter for any type contained in a `@param`,
which skips type parameters that occur in the tag itself.
2020-07-10 08:42:25 -07:00
Ron Buckton
3fdd2342e6 Merge branch 'master' into fix/helpers/use-hasownproperty-call
# Conflicts:
#	tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-esModuleInterop-option-changes.js
#	tests/baselines/reference/tsc/declarationEmit/initial-build/when-pkg-references-sibling-package-through-indirect-symlink.js
2020-07-09 14:57:20 -07:00
Sheetal Nandi
b397d1fd4a Fixes searches for export * as 'identifier' (#39533)
* Fixes searches for export * as 'identifier'
Fixes #39006

* Fix the context span to export declaration (was incorrectly set to sourceFile in prev commit)
2020-07-09 13:45:43 -07:00
ShuiRuTian
bf1ea6508b fix static method reference non-static (#38730)
* fix static method reference non-static

* fix contextRangeIndex

* fix lint.

* fix style.

* update according to suggestion.

* continue fix.

* use every rather than foreach

* format

* fix

* add comment.

* fix according to review suggestions.

* Update src/services/findAllReferences.ts

* Update src/services/findAllReferences.ts

* Update src/services/findAllReferences.ts

* Update src/services/findAllReferences.ts

* Update src/services/findAllReferences.ts

Co-authored-by: Song Gao <song.gao@laserfiche.com>
Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
2020-07-09 12:21:12 -07:00
Jesse Trinity
8e9de9bed2 Fix39458 (#39508)
* remove undefined from optional parameter

* accept baselines

* use getTypeWithFacts
2020-07-09 11:17:18 -07:00
Alexander T
7c99086eb8 fix(39524): convert access property suggestion to string (#39527) 2020-07-09 11:08:44 -07:00
Andrew Branch
03c79d7422 Insert auto-imports in sorted order (#39394)
* Sort auto-imports

* Avoid re-checking sort all the time

* Add comment
2020-07-08 15:25:04 -07:00
csigs
468201a4a7 LEGO: check in for master to temporary branch. 2020-07-08 22:11:10 +00:00
Nathan Shively-Sanders
007b82f6d1 Better checking of @param/@property tags (#39487)
* More consistent checking of @property/@param

1. Use getWidenedTypeForVariableLikeDeclaration, instead of directly
calling tryGetTypeFromEffectiveTypeNode. This requires some changes in
the former function since it can't assume that the declaration has an
initializer.
2. isOptional now calls isOptionalJSDocPropertyLikeTag.
3. isOptionalJSDocPropertyLikeTag now handles JSDocPropertyTag
(previously it was named isOptionalJSDocParameterTag).

* rename to isOptionalJSDocPropertyLikeTag
2020-07-08 13:55:18 -07:00
Alexander T
48c19eebaf fix(25155): add space before optional parameters/properties (#38798) 2020-07-08 13:38:15 -07:00
Sheetal Nandi
0f86c04af3 Fixes searches for symbols exported using export * as (#39507)
Fixes #39006
2020-07-08 13:31:21 -07:00
Alexander T
ebac7ec08f fix(39421): omit prefix text for rest binding element (#39433) 2020-07-08 13:25:28 -07:00
Sheetal Nandi
305c58b03a Remove unnecessary assert (#39483)
This assert made no sense sine we donot use the value from existing structureIsUsed at all
Fixes #36718
2020-07-08 11:02:07 -07:00
csigs
ab79eb2dc2 LEGO: check in for master to temporary branch. 2020-07-08 16:10:43 +00:00
Nathan Shively-Sanders
53a756ea63 Type this in more constructor functions (#39447)
* Type `this` in more constructor functions

Previously,  `this: this` in constructor functions only when there was
an explicit `@constructor` tag on the function. Now, `this: this` for
any function that's known to be a constructor function.

This improves completions inside constructor functions; also note that
previously the compiler *did* type `this: this` inside methods of constructor
functions, so this fix makes us more consistent. This is reflected in
the large number of baselines that improve.

The fix is a simple switch to `isJSConstructor`, which is the standard
way to detect constructor functions. I'm not sure why the original PR
didn't use this method.

I remember discussing this limitation in the original bug, #25979, and
I guess I decided that it made sense. But I was heavily primed by the bug's
framing of the problem in terms of `noImplicitThis`, which *should*
require an explicit `@constructor` tag.

With better typing comes better detection of `@readonly` assignment; I
had to fix the readonly detection code to use `isJSConstructor` as well.

* Remove `Add @class tag` fix for noImplicitThis.

The new rules mean that it never applies. It's possible that it should
apply to functions like

```js
function f() {
  this.init()
}
```

In which `init` is never defined, but I think this program is incomplete
enough that not offering the fix is fine.

* Fix precedence of `@this`

Previously, both `@class` and `@this` in a jsdoc would cause the `@this`
annotation to be ignored. This became a worse problem with this PR,
because `this` is correctly typed even without the annotation.

This commit makes sure that `@this` is checked first and used if
present.
2020-07-08 08:44:17 -07:00
csigs
41ab50be26 LEGO: check in for master to temporary branch. 2020-07-08 10:10:42 +00:00
csigs
371089bdf3 LEGO: check in for master to temporary branch. 2020-07-08 04:10:45 +00:00
Anders Hejlsberg
8c6b85835f Properly handle rest parameters in function declarations with @type annotations (#39473)
* Properly handle rest parameters in function declarations with @type annotations

* Add tests
2020-07-07 16:35:37 -07:00
Wesley Wigham
d2b32b422f Ensure type/namespaceish statics are included in the list of namespace merge members (#38920)
* Ensure type/namespaceish statics are included in the list of namespace merge members

* Simplit into two lines

* Update baseline post-merge
2020-07-07 16:28:09 -07:00
Andrew Branch
2d6d5db33a Fix getTypeAtLocation for dotted implements clauses (#39363)
* Fix getTypeAtLocation for dotted implements clauses

* Fix typo
2020-07-07 16:17:07 -07:00
Wesley Wigham
4f375552b5 Fix crash in decorator metadata calculation when serializing template literal type nodes (#39481) 2020-07-07 15:29:52 -07:00
Ron Buckton
1359dbd6ca Merge branch 'master' into migrateMapsAndSets 2020-07-07 15:14:00 -07:00
Ron Buckton
189e883cb9 Move deprecated jsdoc tags to compat/deprecations.ts 2020-07-07 14:01:27 -07:00
Sheetal Nandi
c08c059dae Dont include auto type reference directives (#39472) 2020-07-07 13:58:53 -07:00
Ron Buckton
9d5cd280ef Merge branch 'master' into migrateMapsAndSets
# Conflicts:
#	src/compiler/checker.ts
#	src/compiler/commandLineParser.ts
#	src/compiler/core.ts
#	src/compiler/moduleNameResolver.ts
#	src/compiler/transformers/declarations.ts
#	src/compiler/tsbuildPublic.ts
#	src/compiler/types.ts
#	src/compiler/utilities.ts
#	src/harness/client.ts
#	src/server/editorServices.ts
#	src/server/typingsCache.ts
#	src/server/utilities.ts
#	src/services/codefixes/convertToAsyncFunction.ts
#	src/services/documentRegistry.ts
#	src/services/importTracker.ts
#	src/services/refactorProvider.ts
#	src/services/refactors/extractSymbol.ts
#	src/testRunner/unittests/programApi.ts
#	src/typingsInstallerCore/typingsInstaller.ts
#	tests/baselines/reference/api/tsserverlibrary.d.ts
#	tests/baselines/reference/api/typescript.d.ts
2020-07-07 13:53:46 -07:00
Ron Buckton
b100680a3e Fix for relating covered discriminants in unions (#39393) 2020-07-07 13:11:55 -07:00
Andrew Branch
0c75021860 Process type nodes in codefixes/refactors for auto-imports recursively (#39130)
* Process type nodes for auto-imports recursively

* Rename function
2020-07-07 13:11:23 -07:00
Nathan Shively-Sanders
1814e2a5c4 Mark @typedef as a type declaration (#39468)
* Mark @typedef as a type declaration

This is only important right now for marking uses of deprecated tags due
to the way that deprecated type references are computed. But I'm
surprised it hasn't caused problems elsewhere.

Fixes #39466

* Also mark @callback and @enum

Requires making name lookup in isTypeDeclarationName smarter, but this
is only used by services, so shouldn't be too performance sensitive.
2020-07-07 10:37:52 -07:00
Alexander T
6b493f2048 fix(23871): change insertNodeAfter to replaceNode to avoid extra newlines (#38045) 2020-07-07 12:54:03 -04:00
csigs
9d0e213f47 LEGO: check in for master to temporary branch. 2020-07-07 16:10:44 +00:00
Orta Therox
6ebd73c84f Don't narrow against unions of constructor functions with instanceof (#38099)
* WIP

* Only narrows when the union is not all constructors
2020-07-07 11:34:10 -04:00
Nathan Shively-Sanders
9a65658b28 Parse *= separately in types (#39457)
* Parse *= separately in types

Previously, when the scanner produced `*=` as a single token, the type
parser ran special-case code to produce an "optional all type", which
only makes sense when the `=` really should be attached to the `*`. This
is often not the case.

The correct solution, which I missed when I first wrote this code, is to
have the scanner go back and produce a separate `=` token, which is what
this PR does.

* add test from #38551

* we ❤️ semicolons
2020-07-07 08:30:42 -07:00
csigs
4f72ae2638 LEGO: check in for master to temporary branch. 2020-07-07 04:10:42 +00:00
Alexander T
2a92a6ea91 fix(39332): handle quotes preference in interface method signatures (#39348) 2020-07-06 17:00:35 -07:00
Wenlu Wang
453365284c Avoid check for union keys (#39314) 2020-07-06 15:01:05 -07:00
Nathan Shively-Sanders
0d84f210b7 In JS, assignment to void 0 isn't a declaration (#39452)
Previously, property assignments with `void 0` initialisers were treated
like any other values. But this causes us to choke when checking our own
commonjs emit. This is something that happens by mistake a fair amount,
so this PR goes back to treating these assignments as normal
assignments.

This should allow us to check our own emit in loose cases without
harming other code bases, since `void 0` is rarely written by hand.

Note that other errors still happen: noImplicitAny forbids
accessing undeclared properties on object literals, and strictNullChecks
forbids assigning `undefined` to properties with a different type.
However, this change is enough to unblock compilation with
`strictNullChecks: false`.
2020-07-06 14:00:12 -07:00
Daniel Rosenwasser
64696225ab Merge pull request #39418 from a-tarasyuk/feat/25259-diagnostic
feat(25259): Better error report for equals instead of colon in object literals / change diagnostic message
2020-07-06 12:13:49 -07:00
Daniel Rosenwasser
77bf2045d8 Merge pull request #39379 from a-tarasyuk/bug/39346
fix(39346): Intelligent code completion not working in child class with composited base interface
2020-07-06 11:59:30 -07:00
csigs
222e18770d LEGO: check in for master to temporary branch. 2020-07-06 16:10:37 +00:00
ShuiRuTian
f29e03eea5 autocomplete works for const assertion. (#39412)
* fix 39384

* add test
2020-07-06 08:49:50 -04:00
Alexander T
9f8585913b feat(25259): change diagnostic message 2020-07-04 09:05:47 +03:00
csigs
7eeecee3b3 LEGO: check in for master to temporary branch. 2020-07-04 04:10:46 +00:00