Commit Graph

2393 Commits

Author SHA1 Message Date
IdeaHunter
069f73d0f2 Change type narrowing for optional properties 2017-12-06 00:02:36 +03:00
IdeaHunter
9c3c2adfb0 Add initial support for 'in' typeguarding 2017-12-06 00:02:36 +03:00
Andy
8153397e91 Lazily compute signature type predicates (#17600)
* Lazily compute signature type predicates

* Use an instance of IdentifierTypePredicate to represent an unresolved type predicate

* Simplify `getMaybeTypePredicate`

* Invert representation of `resolvedTypePredicate`

* Remove `__unresolvedTypePredicate` type and remember to use `noTypePredicate` instead of `undefined` when in all `createSignature` calls

* Fix style of getTypePredicateOfSignature

* Use in createGetSymbolWalker

* Fix bugs for unions of type predicates

* Code review

* Make noTypePredicate purely an implementation detail of getTypePredictateOfSignature

* Add test

* Add test for #19642

* Add test with reversed order
2017-12-05 08:32:34 -08:00
Andy
37a40561ac Support exponentiation operator in const enums (#20424) 2017-12-04 14:32:25 -08:00
Mohamed Hegazy
59e5bbc393 Make sure autoArrayType is unique, even if no lib is available (#20344)
* Make sure autoArrayType is unique, even if no lib is available

* fix typo
2017-12-01 19:51:14 -08:00
Wesley Wigham
1045d95a44 Always instantiate the extends clause, even in the presence of an error (#20232)
* Still instantiate the extends clause even when theres a noimplicitany error in js

* Only be permissive for JS

* In JS, instantiate classes even when they have too many type arguments, instead of returning unknownType
2017-12-01 21:09:06 -05:00
Anders Hejlsberg
f6b1a1de59 Merge pull request #20404 from Microsoft/fixUntypedFunctionCall
Fix untyped function call on constrained type variable
2017-12-01 17:19:32 -08:00
Anders Hejlsberg
3531bd2b57 Add regression test 2017-12-01 16:54:32 -08:00
Nathan Shively-Sanders
8d7c2a2a77 Merge pull request #20370 from Microsoft/cutoff-inference-for-recursive-mapped-types
Cut off inference for recursive mapped types
2017-12-01 15:10:06 -08:00
Nathan Shively-Sanders
1068ee105d Test:inference to self-referential mapped type
From a self-referential type.
2017-11-30 09:40:43 -08:00
Andrew Casey
3a05363a29 Correct errorForUsingPropertyOfTypeAsType03
Rename didn't work properly in a file with errors, so the test isn't
testing the right thing.
2017-11-29 17:48:58 -08:00
Andrew Casey
cdd3cd4f51 Merge pull request #20335 from amcasey/TS2713
Apply TS2713 to classes
2017-11-29 17:39:32 -08:00
Wesley Wigham
a1669bb431 handle multiline jsx strings correctly, emit escapes in jsx attributes correctly (#20309) 2017-11-29 17:08:51 -08:00
Wesley Wigham
a625dec58a Elide import namespace from which only const enums are used (#20320) 2017-11-29 16:36:17 -08:00
Andrew Casey
170cb9c811 Add baselines for the current state of enum members 2017-11-29 15:57:11 -08:00
Andrew Casey
31c4ca5235 Handle all non-namespace types 2017-11-29 15:49:58 -08:00
Charles Pierce
72da4b8f12 Error when LHS of instanceof is Union of Primitives #18519 (#19063)
* Error when LHS of instanceof is Union of Primitives #18519

* Refactor to allTypesAssignableToKind method and update test

* Use ternary expression instead of if / else blocks
2017-11-28 15:05:06 -08:00
Wesley Wigham
835fae264f Allow possibly undefined destructuring in ambient parameter declarations (#20230) 2017-11-27 23:16:21 -08:00
Anders Hejlsberg
61094ec2ea Merge pull request #20229 from Microsoft/fixParenthesizedAsyncArrowFunction
Fix parenthesized async arrow function
2017-11-22 19:50:35 -08:00
Anders Hejlsberg
3a00b76cff Add regression test 2017-11-22 10:50:49 -08:00
Andy
013ce8e36d Catch illegal jsdoc tags on constructors (#20045) 2017-11-21 21:36:08 -05:00
Wesley Wigham
50866e114a Fix visibility checking of mutually recursive exports (#19929)
* Do visibility painting from collectLinkedAliases in checker to remove statefullness in declaration emit

* Fix #17085

* Add deeply destructured array to test

* Add test case for #18634

* Add PR feedback
2017-11-21 15:06:27 -08:00
Anders Hejlsberg
8c4c529d8e Merge branch 'master' into strictPropertyInitialization 2017-11-17 14:30:23 -08:00
Nathan Shively-Sanders
c698a2b8e5 Merge pull request #19227 from Microsoft/infer-object-type-from-string-literal-to-keyof-T
Infer object type from string literal to keyof T
2017-11-16 15:07:12 -08:00
Charles Pierce
1da35d9dca Treat exhaustive switch as last statement in function #18882 (#20063) 2017-11-16 12:17:26 -08:00
Anders Hejlsberg
3a7a99f7c5 Accept new baselines 2017-11-16 11:08:03 -08:00
Anders Hejlsberg
3357aae2d8 Update tests 2017-11-16 10:58:12 -08:00
Ron Buckton
a21a129abb Merge branch 'master' into dynamicNames 2017-11-15 15:24:05 -08:00
Andy
4b96edf72f Treat ... in jsdoc type as creating a synthetic rest parameter -- not as an array type (#19483)
* Treat `...` in jsdoc type as creating a synthetic rest parameter -- not as an array type

* Change type parsing so `...T[]` parses as `...(T[])` and not `(...T)[]`

* Replace the last parameter with ...args, and make access to it potentially undefined

* Code review
2017-11-15 13:04:08 -08:00
Wesley Wigham
9c51a8534e Synchronize getEntityNameForDecoratorMetadata and serializeUnionOrIntersectionType (#19879) 2017-11-14 14:20:18 -08:00
meyer
36ce7eac5a Update JSX intrinsic element test to match babel’s (#19946)
* Update JSX intrinsic element test to match babel’s

* Update baseline

* Move regex out of isIntrinsicJsxName

* Switch to non-regex intrinsic name test
2017-11-14 09:40:32 -08:00
Wesley Wigham
7d93434f2c Fix crash on non-dts-require (#19980) 2017-11-13 16:41:29 -08:00
Wesley Wigham
3d602936e0 Handle binding elements while looking for invalid await and yield (#19972)
* Handle omitting a node in addCustomPrologue, account for binding elemnts in isInParameterInitializerBeforeContainingFunction

* Use append

* Fix lint
2017-11-13 16:40:08 -08:00
Wesley Wigham
b3d3b781ab Treat {} in T = {} as any in JS files (#19977) 2017-11-13 15:39:08 -08:00
Ron Buckton
804c7d3690 Merge branch 'master' into dynamicNames 2017-11-13 13:24:20 -08:00
uniqueiniquity
0fe0ff7943 Add test 2017-11-13 10:55:33 -08:00
Nathan Shively-Sanders
ef07efe70a Merge branch 'master' into infer-object-type-from-string-literal-to-keyof-T 2017-11-13 08:46:49 -08:00
Wesley Wigham
16efae2433 Consider the commonjs module indicator as a module indicator (#18490)
* Consider the commonjs module indicator as an indicator that something is effectively an external module

* Only use commonjs module indicator when targeting commonjs
2017-11-09 16:49:04 -08:00
Andy
90ae9ffe6e If there is an export default x; alias declaration, disallow other default exports (#19872) 2017-11-09 12:21:37 -08:00
Wesley Wigham
a1014b2b13 Mark all parameters as needed for metadata when one is decorated (#19849)
* Mark all properties as needed for metadata when one is decorated

* Add restarg test
2017-11-09 00:26:33 -08:00
Wesley Wigham
ceaeffa3ab Fix declaration emit for imported export alias specifiers (#19852)
* Badness

* Revert #3641, whose original bug has been fixed by other means

* Add another repro
2017-11-08 18:44:46 -08:00
Nathan Shively-Sanders
90f87ef180 Merge pull request #17765 from tycho01/6229-known-length-tuples
add `strictTuples` flag giving tuples known length
2017-11-08 15:38:39 -08:00
Adrian Leonhard
a1da5bd5af Changed error for setter when emitting declaration with private param type (#18593)
so that error message refers to prop name instead of param name.

Changed getter errors for similar case so they also refer to prop name.

Fixed bug where static getters wouldn't output their specific error.

Fixes #1976
2017-11-08 10:02:39 -08:00
Andy
ef6f9351b5 Fix undefined error for diagnostic for instantiating an abstract class (#19809)
* Fix undefined error for diagnostic for instantiating an abstract class

* Only use the name-less diagnostic
2017-11-08 09:40:53 -08:00
Ron Buckton
ee36e6a2ff Merge branch 'master' into dynamicNames 2017-11-06 17:54:48 -08:00
Wesley Wigham
d79c37cd19 Discriminate contextual types (#19733)
* Discriminate contextual types

* Invert conditional

* Update findMatchingDiscriminantType and baselines
2017-11-06 16:09:35 -08:00
Sean Barag
a46d2705ef Use documentation comments from inherited properties when @inheritDoc is present (#18804)
* Use documentation comments from inherited properties when @inheritDoc is present

The JSDoc `@ineheritDoc` [tag](http://usejsdoc.org/tags-inheritdoc.html)
"indicates that a symbol should inherit its documentation from its
parent class".  In the case of a TypeScript file, this also includes
implemented interfaces and parent interfaces.

With this change, a class method or property (or an interface property)
with the `@inheritDoc` tag in its JSDoc comment will automatically use
the comments from its nearest ancestor that has no `@inheritDoc` tag.
To prevent breaking backwards compatibility,
`Symbol.getDocumentationComment` now accepts an optional `TypeChecker`
instance to support this feature.

fixes #8912

* Use ts.getJSDocTags as per @andy-ms 's recommendation

* Convert @inheritDoc tests to verify.quickInfoAt

* Concatenate inherited and local docs when @inheritDoc is present

* Make typeChecker param explicitly `TypeChecker | undefined`

* Re-accept baseline after switch to explicit `| undefined`

* Update APISample_jsodc.ts to match new getDocumentationComment signature

* Re-accept baselines after rebasing
2017-11-06 13:18:21 -08:00
Wesley Wigham
0593ba27d8 Make getContextualTypeOfApparentType mapType over unions (#17668)
* Instantiate contextual types while in an inferrential context

* Limit scope of instantiation to only when likely needed

* Still get aparent type

* Expand test

* Fix nit

* Handle JSX and array

* Tests for the JSX and Array cases

* After much deliberation and inspection, much simpler fix

After much deliberation and inspection, much simpler fix

Undo

Redo
2017-11-06 12:52:33 -08:00
Wesley Wigham
4f48bf80fe Revised emit for computed property names, including with decorators (#19430)
* Revised emit for computed property names

* Fix downlevel name generation scopes

* Accept slightly more conservative baseline

* First feedback pass

* Reduce number of nonrequired variable declarations and assignments

* Remove side-effect-free identifier references

* skip partially emitted expressions

* Comments, move starsOnNewLine to emitNode

* Put expressions on newlines when inlined in class expressions for consistency

* Update new ref

* Fix typo in comment
2017-11-06 12:51:34 -08:00
Ron Buckton
33e09f9a9d Merge branch 'master' into dynamicNames 2017-11-06 12:05:25 -08:00