Commit graph

15121 commits

Author SHA1 Message Date
Andrew Branch 7119e2b74f
The iteration type of overloaded iterator signatures derives from the intersection of their return types (#39722) 2020-07-30 11:37:04 -07:00
Orta Therox faf128de15
Fix formatting scanner on JSX text that looks like trivia (#39718)
* Fix formatting scanner on JSX text that looks like trivia

* Combine if statements

Co-authored-by: Andrew Branch <andrew@wheream.io>
2020-07-30 13:56:14 -04:00
mshivaku99 bffe3540fa
Issue35876: Give better error message when Classic Module Resolution with incorrect path (#38105)
* added Error 5084 to diagnosticMessages.json

* added test case errorForBareSpecifierWithImplicitModuleResolution1 to tests/cases/compiler

* modified checker.ts to report error 5084 when classic resolution and incorrect path are used

* added baseline changes

* passes all test cases including src/testRunner/unittests/ tests

* Update with feedback

* Make it check whether it is the right module resolution kind

* Use the right diagnostic message in tsserver tests

Co-authored-by: Meera Shivakumar <mshivaku@umich.edu>
Co-authored-by: Orta <git@orta.io>
2020-07-30 13:45:29 -04:00
Eli Barzilay a320e1b554 Make getLocalSymbolForExportDefault look harder for an export
Look for a symbol that has a `.localSymbol` property instead of blindly
using the first one.

Fixes #37829.
2020-07-30 13:09:21 -04:00
Alexander T bae111f0ae
fix(39245): change related diagnostic for missing rest parameter arguments (#39356)
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-07-29 17:25:13 -07:00
Nathan Shively-Sanders 9b2d487392
Fix this-parameter emit for JSDocFunction types (#39814)
* Fix this parameter emit for JSDocFunction types

Previously, parameters with names that were not `new` were treated like
rest parameters. This is incorrect: parameters with the name `this`
should emit a `this` parameter.

Fixes #38550

* ❤️ quote style
2020-07-29 14:11:59 -07:00
Eli Barzilay f2d1531768 Fix location for duplicate function implementation errors
Use only the relevant declarations (by collecting them in the for loop),
and use `declaration` if `getNameOfDeclaration` didn't work (useful for
`export default` with anonymous functions).

Fixes #39804.

Also, use `nodeIsPresent` once, and a random `?.`.
2020-07-29 16:07:00 -04:00
Nathan Shively-Sanders 03b658035d
Make @enum,@this tag construction stricter (#39791)
The type expression is required, so the type should reflect that.
2020-07-28 13:49:42 -07:00
Andrew Casey 79e2ed2e77
Merge pull request #39776 from amcasey/OverloadErrors
Reduce unnecessary error computation
2020-07-28 10:35:22 -07:00
Andrew Branch 1f1521c2f1
Undo accidental change from #39772 (#39779)
* Undo accidental change

* Delete test
2020-07-27 16:55:59 -07:00
Andrew Branch 68ba670467
Add contextual type for generator return type (#39772)
* WIP

* Add contextual type for generator return type
2020-07-27 15:14:47 -07:00
Andrew Casey 195fad23a5 Reduce unnecessary error computation
...during overload resolution.  Based on a trace that was spending 30%
of a (very slow) overload resolution elaborating errors that were then
dropped.
2020-07-27 14:11:24 -07:00
Anders Hejlsberg c5d21e7987
Lower priority for speculative variadic tuple inferences (#39723)
* Inference to [...T, X?] has lower priority than inference to [...T, X]

* Update tests

* Accept new API baselines
2020-07-24 15:00:53 -07:00
Andrew Branch ec33814616
Make AutoImportProviderProject work with symlinked monorepos (#39679)
* Hack everything together

* Add test

* Remove realpath from program

* Ensure symlinked directories are directories

* Revert unnecessary change

* Update baselines

* Use host program realpath on AutoImportProviderProject files before program creation

* Which fixes hasRoots() too

* Apply suggestions from code review

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>

* Lint

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
2020-07-22 13:53:30 -07:00
Wesley Wigham 312a6f0efb
Add a fastpath for comparing common mapped types like Pick which avoids manufacturing intermediate type identities (#39696) 2020-07-22 11:59:16 -07:00
Andrew Branch b834096998
Fix emit/formatting issues in refactors (#39506)
* Fix #37948

* Fix formatter skipping tab/space fixup on comments, handle trailing commas in list closing line count.

Fixes #37944

* Add newline between imports and main body of new file in moveToNewFile

Fixes #37941

* Update baseline (probably broken before?)
2020-07-22 10:31:42 -07:00
Song 8a05707559
Fix 31995: make cached key more precise to avoid returning wrong cached value. (#39670)
* fix 31995

* revert useless change only for debug.

* add test
2020-07-22 12:26:17 -04:00
Song 294a0406e3
not escape unicode char for import path string. (#39463)
* not escape unicode char for import path string.

* fix test.
2020-07-22 11:28:29 -04:00
Sheetal Nandi e92afacc44
Add disableReferencedProjectLoad to stop loading child projects to allow users to disable loading large solutions (#39593)
* Use disableReferencedProjectLoad to stop loading child projects to allow users to disable loading large solutions
Fixes #39144

* Handle indirect references

* PR feedback
2020-07-21 14:24:15 -07:00
Song 5484687384
switch typeof any could be checked for unreachable (#39389)
* switch typeof any could be checked for unreachable

* fix stupid error

* support unknown

* remvoe use less code.

* fix spelling.
2020-07-21 13:51:27 -04:00
Anders Hejlsberg 94d6b4507e
Consistent errors on circular base types (#39675)
* Properly track and report errors on circular base types

* Accept new baselines

* Add regression test
2020-07-20 20:35:47 -07:00
Anders Hejlsberg 5ae4b5d715
Properly preserve numeric string named properties in declaration files (#39658)
* Properly preserve names of properties with numeric literal strings

* Accept new baselines
2020-07-20 10:36:46 -07:00
Sheetal Nandi 3b22339df8
Triple slash references must resolve against the resolved file name (.d.ts and not original source file) since they are rewritten in the .d.ts emit (#39645)
* Add tests corresponding to repro from #37928

* Triple slash references must resolve against the resolved file name (.d.ts and not original source file) since they are rewritten in the .d.ts emit

* Remove the scenario not fixed in this PR
2020-07-17 16:25:32 -07:00
Wesley Wigham 191f4f63ab
Explicitly add dependency on node to compiler tsconfig, remove es6+ string method usage (#39636) 2020-07-17 07:02:05 -07:00
Alexander T 4e24b1b00d
fix(39373): add diagnostic message about using a private name for class declarations without name (#39567) 2020-07-16 17:05:33 -07:00
Sheetal Nandi 667ba74c93
Resolve only relative references in open files on syntax server (#39476)
* Resolve only relative references in open files on syntax server

* Support resolving tripleslash references only in the open file

* Apply suggestions from code review

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2020-07-16 14:31:24 -07:00
Anders Hejlsberg db79030410
Support variadic tuple inference from trailing optional to non-optional (#39614)
* Permit variadic tuple inference from trailing optional to non-optional

* Add tests
2020-07-15 17:46:48 -07:00
uhyo b6f09ccf06
Better error message for unparenthesized function/constructor type notation in union/intersection types (#39570)
* add graceful error message for unparenthesized function types in union and intersection

* add unparenthesizedFunctionTypeInUnionOrIntersection test

* add unparenthesizedConstructorTypeInUnionOrIntersection test

* Update src/compiler/parser.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* pass isInUnionType to parseFunctionOrConstructorTypeToError

* Apply suggestions from code review

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

* syntax fix

* refactor isStartOfFunctionType into isStartOfFunctionTypeOrConstructorType

* Update src/compiler/parser.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* hoist isUnionType

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-07-15 14:43:56 -07:00
Sheetal Nandi 37e6e2761c
Do not resolve require calls in typescript files even if it contains dynamic import (#39617)
* Existing tests showing require in ts file is not used for module resolution

* Do not resolve require calls in typescript files even if it contains dynamic import
Fixes #38611
2020-07-15 14:31:55 -07:00
Wesley Wigham f2c5643056
Flag mapped types with circular property types and do not attempt to print them structurally (#39552) 2020-07-15 11:19:43 -07:00
Wenlu Wang fcd4fcb3d7
Use combined node flags (#39403) 2020-07-15 09:22:12 -07:00
Wenlu Wang 7b728754c0
Fix incorrect deprecated mark (#39611)
* Fix incorrect deprecated mark

* improve test
2020-07-15 08:47:25 -07:00
Andrew Branch dd2fc86f2b
Don’t give all instantiated signatures in JS strict arity (#39606) 2020-07-14 18:56:50 -07:00
Wesley Wigham ef9affe2f6
Use jsxFragmentFactory entity name for factory name lookup from checking fragments (#39475) 2020-07-14 17:25:45 -07:00
Andrew Branch 98ab3a788f
Fix tsc --watch crash on module augmentations when module resolution changes (#39604)
* Add failing test

* Ensure source files are bound before analyzing them
2020-07-14 15:05:10 -07:00
Michael Crane f68a8393ef
Load ETW module from a specified path (#39599) 2020-07-14 11:52:55 -07:00
Jesse Trinity 17022388bd
Add refactor convertToOptionalChainExpression (#39135)
* add convertOptionalChain

* cover more cases

* expose containsMatchingReference

* clean up performing edits

* bound start position

* add tests

* refactor and handle edge cases

* update tests

* consider explicit requests for empty spans

* update fourslash to use trigger reason

* add tests cases for trigger reason

* fix errors

* remove type assertion

* fix non ampersand chains

* clean up some logic

* add ternary case

* add diagnostic message

* add nullish check for ternary expressions

* Update src/services/refactors/convertToOptionalChainExpression.ts

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

* Update src/services/refactors/convertToOptionalChainExpression.ts

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

* Update tests/cases/fourslash/refactorConvertToOptionalChainExpressionForTriggerReason3.ts

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

* Update tests/cases/fourslash/refactorConvertToOptionalChainExpressionForTriggerReason1.ts

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

* reformat and remove unused checks

* allow any for ternary refactor

* add tests

* add tests

* check return and variable statements

* use isMatchingReference instead of containsMatchingReference

* allow partial selections

* fine tune selection ranges

* recurse for call expressions

* fix spellings

* add recursive cases

* remove isOrContainsMatchingReference

* cleanup

* more refactoring

* cleanup

* rename tests

* address PR comments

* check match syntactically

* handle another call expression case

* some renames

* inline some checks

* add test

* address comments

* add refactorNotAvailableReason

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-07-13 19:33:33 -07:00
Ron Buckton 5ad8532a11 Merge branch 'master' into fix37113
# Conflicts:
#	src/compiler/transformers/module/module.ts
2020-07-13 11:13:35 -07:00
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
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
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
Ron Buckton ae2f0068e3 Fix default import/export helper usage 2020-07-09 13:13:48 -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
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
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