11611 Commits

Author SHA1 Message Date
Nathan Shively-Sanders
11929e33ed Address PR comments 2017-02-13 12:54:58 -08:00
Nathan Shively-Sanders
1c7628e653 Improve discriminated union error messages
Assignability errors for discriminated unions now check the value of the
discriminant to decide which member of the union to check for
assignability.

Previously, assignability didn't know about discriminated unions and
would check every member, issuing errors for the last member of the
union if assignability failed.

For example:

```ts
type Square = { kind: "sq", size: number }
type Rectangle = { kind: "rt", x: number, y: number }
type Circle = { kind: "cr", radius: number }
type Shape =
    | Square
    | Rectangle
    | Circle;
let shape: Shape = {
    kind: "sq",
    x: 12,
    y: 13,
}
```

`typeRelatedToSomeType` now checks whether each property in the source
type is a discriminant. It finds `kind` and proceeds to look for the
type in the target union that has `kind: "sq"`. If it finds it, which it
does in this example (`Square`), then it checks only assignbility to
`Square`.

The result is that the error now says that property 'size' is missing in
type `{ kind: "sq", x: number, y: number }` instead of saying that that
"sq" is not assignable to type "cr" like it did before.

Fixes #10867
2017-02-10 14:01:47 -08:00
Mohamed Hegazy
2fc634f460 Merge pull request #13905 from Microsoft/optionalParametersInJSFunctions
Treat function paramters in a .js file with no JSDoc as optional
2017-02-09 16:46:19 -08:00
Mohamed Hegazy
e76607e864 Fix typo 2017-02-09 16:24:32 -08:00
Mohamed Hegazy
a47c47611f Respond to code review comments 2017-02-09 15:25:49 -08:00
Mohamed Hegazy
4ec68481ba Merge pull request #13903 from Microsoft/jsPropertyWidening
Widen special JS property declarations to match regular property declarations
2017-02-09 15:08:35 -08:00
Mohamed Hegazy
24ddbe4b60 Widen after sub-type-reduction took place 2017-02-09 14:55:07 -08:00
Mohamed Hegazy
47203c5c3a Merge pull request #13983 from Microsoft/lintFixes
Fix lint failures detected by tslint@4.4.2
2017-02-09 13:02:10 -08:00
Nathan Shively-Sanders
270c0b80d9 Merge pull request #13959 from Microsoft/fix-assigned-type-of-assignment-nested-in-literals
Fix assigned type of assignment nested in literals
2017-02-09 12:59:46 -08:00
Yui
f7b20624cf Merge pull request #13916 from Microsoft/master-fix13602
[Master] Fix 13602 preserve comment following element in node list
2017-02-09 12:51:22 -08:00
Mohamed Hegazy
84fc29f900 Fix lint failures detected by tslint@4.4.2 2017-02-09 12:46:09 -08:00
Kanchalai Tanglertsampan
8da2bd97bd Address code review 2017-02-09 12:32:50 -08:00
Vladimir Matveev
2480e8d492 do secondary lookup only if module has non-relative name 2017-02-08 20:35:01 -08:00
Kanchalai Tanglertsampan
8b8c490ff6 Address code review: fix indentation 2017-02-08 13:36:19 -08:00
Nathan Shively-Sanders
125dd57a75 Fix assigned type of assignment nested in literals
Fixes #12946
2017-02-08 13:28:23 -08:00
Vladimir Matveev
bb71dcdde8 add projectUsesOutFile field to protocol.CompileOnSaveAffectedFileListSingleProject (#13915) 2017-02-08 11:01:32 -08:00
Kanchalai Tanglertsampan
a928ad3bd3 Address code review: move only expose emitLeadingCommentsOfPosition 2017-02-08 10:17:58 -08:00
Andy
51d4970ce0 Merge pull request #13760 from Microsoft/find_all_refs_tests
Change find-all-references tests to test for groups
2017-02-08 07:05:36 -08:00
Andy Hanson
f4583313d9 Use !! to convert to boolean 2017-02-08 06:13:32 -08:00
Vladimir Matveev
915ffab8cc disable fs watcher for UNC paths on Windows (#13937) 2017-02-07 14:47:07 -08:00
Nathan Shively-Sanders
363d91425e Merge pull request #13791 from Microsoft/typeof-string-literal-union-type
`typeof x` now has a string literal union type
2017-02-07 13:19:08 -08:00
Nathan Shively-Sanders
bcd1ef8477 Merge branch 'master' into typeof-string-literal-union-type 2017-02-07 12:59:39 -08:00
Kanchalai Tanglertsampan
80eae169ee Emit leading comment before brace token 2017-02-07 11:56:44 -08:00
Ron Buckton
a7728f8fa1 Clean up extraneous file 2017-02-07 11:24:05 -08:00
Nathan Shively-Sanders
94aeff2a2c Merge pull request #13914 from Microsoft/forward-ref-in-property-initialisers
Error on forward references in property initializers
2017-02-07 07:37:02 -08:00
Kanchalai Tanglertsampan
188e9df9b5 Emit missing trailing comment of an element in node list 2017-02-06 18:13:17 -08:00
Nathan Shively-Sanders
c28edc31c0 Error on forward references for property initializers
The error only appears when a property initializer references another
property before its definition. References to outer variables, etc are
still allowed.
2017-02-06 15:53:00 -08:00
Ron Buckton
955b10edf9 Merge pull request #13825 from Microsoft/publicNodeFactories
Make most current Node factory functions public
2017-02-06 15:43:40 -08:00
Ron Buckton
eedc2619db Minor PR feedback 2017-02-06 15:28:54 -08:00
Mohamed Hegazy
82a3feaadc Treat function paramters in a .js file with no JSDoc as optional 2017-02-06 11:54:13 -08:00
Mohamed Hegazy
914150f2f1 Widen special JS property declarations to match regular property declarations 2017-02-06 09:57:12 -08:00
Ron Buckton
9a65a66423 Fix linter error 2017-02-04 22:46:38 -08:00
Zhengbo Li
501084a93c Merge pull request #13856 from zhengbli/updateLib20170202
Routine lib files update
2017-02-03 15:17:05 -08:00
Ron Buckton
bd98bc97bd Add factory functions for rest of NodeEdgeTraversal 2017-02-03 14:12:50 -08:00
Ron Buckton
7a539d0b85 Identifier escaping/unescaping for unique names 2017-02-03 12:40:39 -08:00
Zhengbo Li
df643d8d02 Merge pull request #13405 from zhengbli/13137
Support import fix for missing namespace
2017-02-02 16:11:08 -08:00
zhengbli
5f1fafce5e routine lib files update 2017-02-02 15:25:05 -08:00
zhengbli
62f716aaa6 avoid removing comments when removing unused locals 2017-02-02 13:50:34 -08:00
Zhengbo Li
6c56b3d957 Fix casing in import quick fix 2017-02-02 02:17:49 -08:00
Ron Buckton
a72abc8ebc Make getOriginalNode/getParseTreeNode public 2017-02-01 19:41:28 -08:00
Ron Buckton
ff4c72de00 Make most current Node factory functions public 2017-02-01 16:36:10 -08:00
Ron Buckton
bc611d9e7d Merge pull request #13761 from Microsoft/extractPrinter
Expose printing functionality of emitter as a public API
2017-02-01 16:29:29 -08:00
Ron Buckton
984541316a Added comments and a few Debug assertions 2017-02-01 16:16:04 -08:00
Ron Buckton
f02ce1f6a0 PR Feedback 2017-02-01 15:22:35 -08:00
Nathan Shively-Sanders
d23f692734 rename arrayFromMap -> convertToArray 2017-02-01 13:11:16 -08:00
Anders Hejlsberg
86b3c14099 Consider 'object' a valid base type + apparent type of 'object' is {} 2017-02-01 11:36:33 -08:00
Andy
207f1aa5c9 Merge pull request #13786 from Microsoft/ata
Use "ts2.2" (or "ts2.3", etc.) NPM tag in typingsInstaller
2017-02-01 10:32:18 -08:00
Anders Hejlsberg
ddf4f45973 Merge pull request #13817 from Microsoft/fixIndexedAccessApparentType
Fix indexed access apparent type
2017-02-01 08:23:58 -10:00
Anders Hejlsberg
15c6022e40 Fix typo causing bug 2017-02-01 09:32:33 -08:00
Mohamed Hegazy
a39c14ec2e Factor kind check to a separate function 2017-01-31 21:34:25 -08:00