3519 Commits

Author SHA1 Message Date
Nathan Shively-Sanders
d3877d294c
Redo in narrowing for intersections (#39637)
* Redo in-narrowing for intersections

Still need to carve out an exception for globalThis

* exempt globalThis from `in` narrowing
2020-07-30 14:58:22 -07: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
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
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
Alexander T
92f41c81fb
tests(39373): add addition tests (#39631) 2020-07-17 13:30:57 -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
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
Wesley Wigham
ef9affe2f6
Use jsxFragmentFactory entity name for factory name lookup from checking fragments (#39475) 2020-07-14 17:25:45 -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
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
Ron Buckton
ae2f0068e3 Fix default import/export helper usage 2020-07-09 13:13:48 -07:00
Alexander T
7c99086eb8
fix(39524): convert access property suggestion to string (#39527) 2020-07-09 11:08:44 -07:00
Ron Buckton
5c5f180f8e Fix namespace import/export helper usage 2020-07-07 17:36:59 -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
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
Anders Hejlsberg
2fe2f88047
Fix control flow analysis for nested try-catch-finally statements (#39399)
* Fix control flow analysis for nested try-catch-finally statements

* Add tests
2020-07-03 09:51:01 -07:00
Wesley Wigham
ff1f449b99
Fix type of computed name following spread (#39319) 2020-06-30 13:37:59 -07:00
ShuiRuTian
4601a786aa
not narrow static property without type annotation in constructor. (#39252)
* fix #39226

* fix lint.
2020-06-26 11:08:35 -07:00
Wesley Wigham
a3ee09ddc9
Handle recursive type references up to a certain level of expansion in inference (#38011)
* Handle recursive type references up to a certain level of expansion in inference

* Move object cases into the same conditional branch
2020-06-24 14:24:34 -07:00
Wesley Wigham
d1ebf126d2
Do not consider binding patterns in contextual types for return type inference where all the signature type parameters have defaults (#39081) 2020-06-24 13:45:17 -07:00
Wesley Wigham
7893c9fc7e
Do not add reexported names to the exportSpecifiers list of moduleinfo (#39213) 2020-06-23 17:56:44 -07:00
Daniel Rosenwasser
e6aedfd38b
Merge pull request #37907 from Jack-Works/feat/class-to-classname
feat: add a codefix to fix class to className in react & add spelling suggest for JSX attributes
2020-06-22 18:32:24 -07:00
ShuiRuTian
d76e85d94e
Update bigint declaration file (#38526)
* update toLocalString function signature

* update test.

* fix lint

* follow review advice.

* format and better comment.

* format

* add case

* fix symbol.

* remove subtype and string union in interface.

* remove useless code.

Co-authored-by: Song Gao <song.gao@laserfiche.com>
2020-06-22 14:55:04 -07:00
Jack Works
ffb35a3eb1 test: add test for it 2020-06-19 10:50:35 +08:00
Noj Vek
f697d26ca1
reset soft with master for single commit (#38720) 2020-06-18 00:22:32 -07:00
Dmitri
0bc29acc08
Add a type-guard overload of Array.every (#38200)
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-06-17 13:02:30 -07:00
Eli Barzilay
7611579421 Small fix in getObjectLiteralIndexInfo
Fixes #38175
2020-06-17 03:29:10 -04:00
Eli Barzilay
f560560f82 Fix two test typos 2020-06-17 03:28:55 -04:00
Wesley Wigham
6a777ff6b3
Fix crash when serializing the return type of a generic call to Array.prototype.flat (#38904)
* Add declaration emit error and checking for circularly referential unions produced by recursive conditionals

* Allow indexed accesses to produce alias symbols on types

* Add test that still triggers the declaration emit error

* Fix spelling
2020-06-15 11:46:10 -07:00
Eli Barzilay
0432954f2d Small fix in getIsContextSensitiveAssignmentOrContextType
Test that `parentSymbol.valueDeclaration` exists.

Fixes #38532
2020-06-13 07:10:04 -04:00
Eli Barzilay
8231519b85 Simplify visitObjectLiteralExpression
I ran into it and the comment at the top tripped me, then I proceeded to
simplify the code.  Patched a bit more of the function to make sure that
the indentation doesn't change, and added tests.
2020-06-13 07:05:21 -04:00
Eli Barzilay
f447838f95 Fix handling of aruments in the emitter
Two problems are fixed:

* `isArgumentsLocalBinding` did only `PropertyAccessExpression`, now
  it's also doing `PropertyAssignment` (doesn't affect other files,
  since it's only used in the emitter).

* `visitShorthandPropertyAssignment` should call `visitIdentifier` on
  the synthesized id.  (For completion it might be better to make it
  visit the the original?)

Fixes #38594.
2020-06-13 07:05:21 -04:00
Andrew Branch
b63ea4b6df
Fix declaration emit for property references of imported object literal types (#39055)
* Fix declaration emit for property references of imported object literal types

* Add declaration file to test
2020-06-12 17:48:19 -07:00
Eli Barzilay
ffa35d3272 Allow e: unknown in catch arguments
In addition, allow an explicit `any`; anything else throws an error.

Also adjust and reorganize existing tests.

Fixes #36775.
2020-06-10 18:24:20 -04:00
Wesley Wigham
08cb0b23e8
Serialize (noncontextual) keyword named namespace members with export declarations in both declaration emitters (#38982)
* fix(38750): create unique names for keywords and re-export them with original names

* Serialize (noncontextual) keyword named namespace members with export declarations in both declaration emitters

* Add exhaustive keyword emit test for js declaration emitter and fix it up

Co-authored-by: Alexander T <alexander.tarasyuk@outlook.com>
2020-06-10 14:42:49 -07:00
Andrew Branch
0d6ae004d7
Fix isSameEntityName (#38999)
* Fix isSameEntityName

* Add baseline

* Fix baseline
2020-06-10 10:53:02 -07:00
Wesley Wigham
f41398e100
Make isEntityNameVisible duplicate the node builder logic to always consider type parameters as visible if they are the resolution result (#38921) 2020-06-09 13:40:17 -07:00
Eli Barzilay
4ee013d1a7 Fix merging of JS value & TS type decl
Fixes #38383
2020-06-04 19:28:33 -04:00
Anders Hejlsberg
c5b8f4fcd4
Fix relation between generic mapped types and types with index signatures (#38761)
* Fix relation between generic mapped type and type with index signature(s)

* Add tests
2020-05-25 09:55:41 -07:00
Nathan Shively-Sanders
fc83d10388 Merge branch 'master' into diagnose-accidental-accessor-call 2020-05-20 16:46:34 -07:00
Nathan Shively-Sanders
3340142dda
Merge pull request #38607 from a-tarasyuk/bug/38295
fix(38295): Duplicated object key in const not detected when the key is a number preceded by `-` or `+`
2020-05-20 14:52:09 -07:00
Alexander T
4e945fbc98
fix(38299): use string literals as keys to creating rest result (#38600) 2020-05-20 13:52:52 -07:00
Alexander T
bbf56b044b Merge branch 'master' of https://github.com/microsoft/TypeScript into bug/38295 2020-05-20 20:13:50 +03:00
Alexander T
e04ab6938a fix(38295): handle duplicate object literal keys which contain '+' and '-' tokens 2020-05-20 14:32:41 +03:00
Anders Hejlsberg
7ba0a6592d
No contextual types from circular mapped type properties (#38653)
* No contextual types from circular mapped type properties

* Add regression test
2020-05-19 13:42:30 -07:00
Anders Hejlsberg
3c1f37e913
Use control flow analysis to check 'super(...)' call before 'this' access (#38612)
* Use CFA graph to check this/super accesses are preceded by super() call

* Accept cleaned-up API baselines

* Accept new baselines

* Add tests
2020-05-16 19:58:17 -07:00