Commit Graph

16170 Commits

Author SHA1 Message Date
Anders Hejlsberg
8e5a84a696 Exclude mapped types with optionality modifiers and 'as' clauses from constraint logic (#48273)
* Exclude mapped types with optionality modifiers and 'as' clauses

* Add regression tests
2022-03-15 17:37:46 -07:00
Jesse Trinity
111ca92646 Fix parser regression for bad related diagnostic on missing matching brackets (#44158)
* Revert "Revert #43460 and #40884 (#44175)"

This reverts commit 5770434891.

* fix missing opening brace match error

* refactor parseExpectedMatchingBrackets

* use getNodePos

* accept baselines

* delete mistakenly added files

* Revert getNodePos addition

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-03-15 17:29:41 -07:00
Anders Hejlsberg
8c060eecaa Exclude mapped types with 'as' clauses from certain checks (#47889)
* Exclude mapped types with 'as' clauses from certain checks

* Add tests
2022-03-15 17:01:33 -07:00
Wenlu Wang
5f017df609 Fix top level logical assignment leak (#40536)
* Fix leaking top level logical assignment

* Fix leaking top level logical assignment
2022-03-14 10:48:31 -07:00
Oleksandr T
4a58fbce17 fix(48081): omit error on importing variables defined with require() (#48115) 2022-03-14 09:55:12 -07:00
Andrew Casey
ce9657d5e2 Introduce set with custom equals and getHashCode (#48169)
* Implement set with custom equals and getHashCode

* Adopt custom set in session

* Add doc comment

* Initially store buckets as non-arrays
2022-03-11 16:17:54 -08:00
Wesley Wigham
93c3a30edc Add assertion on invalid cache set (#43845) 2022-03-11 10:57:22 -08:00
Wesley Wigham
d1fa945261 Add moduleDetection compiler flag to allow for changing how modules are parsed (#47495)
* Add moduleDetection compiler flag to allow for changing how modules are parsed

The default setting is 'auto', where JSX containing files under react-jsx and react-jsxdev are
always parsed as modules, and esm-format files under module: node12+ are always parsed as modules,
in addition to the 'legacy' detection mode's conditions for other files. (Declaration files are exempt from
these new conditions)

The 'legacy' mode preserves TS's behavior prior to the introduction of this flag - a file is
parsed as a module if it contains an import, export, or import.meta expression.

In addition, there is a 'force' mode that forces all non-declaration files to be parsed as modules.
(Declaration files are still only modules if they contain a top-level import or export.)

This technically breaks the parser API, but it's kinda-sorta backwards compatible so long
as you don't need the functionality associated with more recent compiler flags.

* Fix post-merge lint

* Rename function

* Update default value documentation

* PR feedback

* Fix lint and typo
2022-03-11 10:36:00 -08:00
Anders Hejlsberg
0271738047 Properly reduce intersections to never in identity relation (#48111)
* Exclude types that may simplify to other forms

* Add regression test
2022-03-11 10:18:04 -08:00
Mateusz Burzyński
04238e6f52 Fix/dependent parameters obj methods (#48110)
* Add failing test for dependent destructured variables within obj methods

* Fixed an issue with dependent parameters within obj methods
2022-03-11 09:46:30 -08:00
Wesley Wigham
3f63804878 Make direct assignments to cjs exports considered literal contexts (#39816)
* Make direct assignments to cjs exports considered literal contexts

* Style feedback from PR

* Trailing whitespaaaaace
2022-03-09 13:27:39 -08:00
Wesley Wigham
f76452cb27 Fix conditional type type parameter leak (#31455)
* Fix conditional type type parameter leak

* Monkey with comment text per code review

* Conditionally clone type param

* Reuse input array and avoid making mapper where possible
2022-03-09 13:25:14 -08:00
Wesley Wigham
fc82c67357 Don't eagerly simplify reducible generic union index types (#46812) 2022-03-09 12:02:11 -08:00
Wesley Wigham
ea4791d4d7 Preserve the homomorphism of inlined mapped types in declaration emit (#48091) 2022-03-09 10:31:54 -08:00
Nathan Shively-Sanders
918f0ef404 Rename SyntaxKind.JSDocComment -> JSDoc (#44416)
* Rename SyntaxKind.JSDocComment -> JSDoc

Early on, I made the mistake of using the syntax kind JSDocComment for
the type JSDoc. This arose because
I hadn't decided on the terminology of "jsdoc" for the C-style comment
that is attached to a declaration. "comment"
for the text that follows a tag. By the time I settled on those terms
consistently, a version had already shipped with `interface JSDoc`
having `SyntaxKind.JSDocComment`.

However, there is now a `type JSDocComment` that represents the possible
contents of the comment text (strings and various kinds of `@link`), so
it's doubly confusing that this type has a union of four kinds instead
of SyntaxKind.JSDocComment.

Although this is a public API break, I don't think it's hard to recover
from, and the JSDoc API has accessors for individual tag types, so I
suspect few people refer directly to SyntaxKind.JSDocComment.

* Add deprecate JSDocComment alias to JSDoc

For backward compatibility

* Make JSDoc an alias of JSDocComment

Improves output of JSDocParsing tests without having to make its code
smarter.

* update API baselines
2022-03-09 09:51:29 -08:00
Jack Bates
94a7ec17e0 🤖 Sync option descriptions <- website (#46465)
* 🤖 Sync option descriptions <- jablko/TypeScript-Website@a9df5139f2

https://github.com/jablko/TypeScript-Website/actions/runs/1953829438

* Update Baselines and/or Applied Lint Fixes

Co-authored-by: jablko/TypeScript-Website:.github/workflows/sync-option-descriptions.yml <bot@typescriptlang.org>
Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
2022-03-08 15:55:13 -08:00
Ryan Cavanaugh
af027f34fa Bail on 0- and 1-length lists in removeSubtypes to avoid spurious circularity problems (#46981)
* Creates a reasonable workaround for #46939

* Remove unrelated newline

* Do the cheap length check ahead of the cache check

* Actually do it.
2022-03-08 08:50:07 -08:00
Jake Bailey
d8b21a8d6c Don't crash on non-literal computed property names during getPropertyAssignment (#48079) 2022-03-07 14:18:55 -08:00
jihndai
5f6ebf9d78 Show error when trying to instantiate a union of abstract and concrete constructors (#48114)
* check composite signatures for abstract flag

* add tests and baselines

* refactor someSignature into a single function
2022-03-04 17:39:05 -08:00
jihndai
857889a4e6 Fix crash when this is typed as a generic T with no type constraints (#47991)
* fix this type validations for protected fields

* update previous baselines

* add new tests and baselines

* ClassOrInterface can be returned as enclosingClass

* inline function code and remove unnecessary blank lines

* refactor enclosingClass checks
2022-03-04 17:08:44 -08:00
Oleksandr T
82fc9b19ba fix(43154): emit typeof type for static methods with a computed name (#46923) 2022-03-04 17:07:38 -08:00
Jack Bates
d12020d8b0 Describe jsxFragmentFactory option default value (#46798) 2022-03-04 17:03:55 -08:00
Oleksandr T
162713fac9 fix(40617): handle uninitialized class member with computed key (#45974) 2022-03-04 16:03:36 -08:00
Zzzen
f9ae305dda support generic type when checking implicit conversion of symbol to string (#44578)
Co-authored-by: Wesley Wigham <wewigham@microsoft.com>
2022-03-04 15:57:34 -08:00
Erik Brinkman
751c114126 Fix contextual discrimination for omitted members (#43937)
In short, the fix I submitted looked at the union ofproperties, but it
really should have looked at the intersection.

Two sytlistic notes. I couldn't find the best way to get the unique
strings of an array like `[...new Set()]` would, so I created a small
helper function, but didn't put it in a great place. Also, before the
second concatenated array of discriminators at least matched the first
in complexity, but now it's much worse. I don't think that section is
particularly easy to read, but I also don't see a significantly reusable
part.

fixes #41759
2022-03-04 14:07:37 -08:00
liewrichmond
ae62da9413 Fixes #35735: Avoids listing missing properties for types with only call/construct signatures (#40973)
* Fixes #35735

* fixes #35735

* PR feedback

Co-authored-by: Wesley Wigham <wewigham@microsoft.com>
2022-03-04 13:54:38 -08:00
Oleksandr T
5f9f9e3752 fix(44477): emit full path to access expressions in comments (#44545)
Co-authored-by: Wesley Wigham <wewigham@microsoft.com>
2022-03-04 11:22:46 -08:00
magic-akari
06d426c966 Fix const enum comments (#47990)
* chore: add test case

* fix: const enum comment

* fix: replace all unsafe pattern

* chore: run regex only if element access
2022-03-03 09:10:02 -08:00
Wesley Wigham
f82d0cb329 Add explicit assertion on somewhat commonly incorrectly passed argument (#48078)
* Add explicit assertion on somewhat commonly incorrectly passed argument

* PR feedback
2022-03-02 09:13:42 -08:00
Wesley Wigham
ea0db9e031 Add import assertions to type only imports and import types to force the resolution mode of the specifier (#47807)
* Add import assertions for type-only imports and import types to change resolver modes

* By popular request, only allow mode assertions on top-level type only imports

* Add specifier options parameter to specifier generation
2022-03-02 08:54:10 -08:00
Wesley Wigham
ff1f7b15b7 Esm imports of cjs files should unconditionally have a default patched on (#48062) 2022-03-02 08:53:31 -08:00
Oleksandr T
063714886e fix(47946): check literal types in export assignments with declared JSDoc types (#47951) 2022-03-01 14:44:36 -08:00
Jake Bailey
e4fe50cca4 Fix incorrect parser error assumption in semicolon handling leading to incremental parser brokenness (#48067) 2022-02-28 17:05:32 -08:00
Wesley Wigham
71918750f9 Use full isReadonlySymbol check rather than declaration flags (#48064)
* Use full `isReadonlySymbol` check rather than declaration flags

* Limit subtype readonly consistency check to strict subtype relation

* Update comment
2022-02-28 14:35:33 -08:00
jihndai
1abc47b882 Add Intl.Locale parameter type to toLocale[X]String signatures. (#47811)
* add Intl.Locale param type to locales argument in BigInt, Number, and Date methods

* update baselines

* add test for locales object arguments

* fix indentation
2022-02-28 14:10:18 -08:00
Wesley Wigham
03c11c8f70 Add missing getReducedType call in getConditionalTypeInstantiation (#48061) 2022-02-28 13:41:10 -08:00
Nobuyuki Tsutsui
0043abe982 Expose text property of SourceFileLike for some Public APIs (#44599)
* Expose text property of SourceFileLike

* gulp baseline-accept
2022-02-25 14:29:08 -08:00
Jake Bailey
2dede207ae Don't treat a colon in a conditional expression branch as part of an arrow function (#47550) 2022-02-25 13:08:18 -08:00
Gabriela Araujo Britto
733eff2b10 Revert "Use related spans for "implement abstract class" errors" (#48029) 2022-02-24 16:15:31 -08:00
Gabriela Araujo Britto
4b395c6097 Merge branch 'related-spans-for-implement-abstract-class-error' of https://github.com/FlyingPumba/TypeScript into FlyingPumba-related-spans-for-implement-abstract-class-error 2022-02-24 16:11:03 -08:00
islandryu
ff3b458714 fix(47158): Removes comments when line variable declaration (#47407)
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
2022-02-23 09:33:41 -08:00
Gabriela Araujo Britto
78818e0390 early return if pattern type is never (#47927) 2022-02-22 17:34:02 -08:00
Nathan Shively-Sanders
5150682a58 Only suggest @param codefixes in TS (#47959)
* Only issue @param suggestions with codefixes in TS

Previously, there were 2 JS errors that were issued as suggestions in TS
files. But there was no codefix for these errors, and the errors were
incorrect in TS.

This PR only issues the JS-specific errors on JS files.

* Minimise test
2022-02-18 15:58:09 -08:00
Josh Goldberg
92204983f4 Standardized aka.ms links for tsc and tsconfig (#47129)
* Standardized aka.ms links for tsc and tsconfig

* Three missed baselines

* Three last baselines

* Went back to aka.ms/tsconfig
2022-02-18 12:09:15 -08:00
Anders Hejlsberg
db226a80e8 Remove unnecessary check in getNarrowableTypeForReference (#47953)
* Remove unnecessary check in getNarrowableTypeForReference

* Add regression test
2022-02-18 11:03:48 -08:00
DetachHead
092018bd7e fix issue where duplicate default exports aren't detected (#46871)
* fix issue where duplicate default exports aren't detected when there's an interface

* accept baseline change

* add `exportDefaultInterfaceClassAndValue` test

* add more tests for multiple default exports

* add two interfaces test

Co-authored-by: DetachHead <detachhead@users.noreply.github.com>
2022-02-17 13:17:31 -08:00
Jonas Hübotter
fb1066e5d9 Uncalled function checks only works with single conditional (#42835)
* Uncalled function checks only works with single conditional

* fix type errors in compiler

* remove uncalled function checks with negations

* review

* fix test

* Cleanup after merge, accept baselines

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-02-17 11:37:55 -08:00
Anders Hejlsberg
53809d8ed1 Remove unnecessary check for misaligned complex rest parameters (#47934)
* Remove unnecessary check for misaligned complex rest parameters

* Add tests
2022-02-17 11:35:52 -08:00
Anders Hejlsberg
5afbfbcbd0 Instantiation expressions (#47607)
* Permit type arguments in references to generic functions

* Accept new baselines

* Delete pointless fourslash test

* Fix lint issue

* Finalize implementation

* Add tests

* Accept new baselines

* Properly handle instantiation of instantiation expression types

* Accept new API baselines

* Fix lint error

* Add more tests

* Properly handle unions/intersections of generic types

* Add more tests

* More permissive parsing of type arguments in member expressions

* Update tests

* Accept new baselines
2022-02-16 13:27:16 -08:00
Oleksandr T
b9a06e515f fix(47261): allow linkcode/linkplain tags in see tag (#47403) 2022-02-15 17:20:51 -08:00