Commit graph

629 commits

Author SHA1 Message Date
Anders Hejlsberg
e0d210d027 Add tests 2018-10-30 08:18:18 -07:00
Nathan Shively-Sanders
64ff195426
Set-only accessors spread to undefined (#28213)
* Set-only accessors spread to undefined

Previously they were skipped. The runtime behaviour is to create a
property of type undefined, unlike (for example) spreading numbers or
other primitives. So now spreading a set-only accessor creates a
property of type undefined:

```ts
const o: { foo: undefined } = { ...{ set foo(v: number) { } } }
```

Notably, `o.foo: undefined` not `number`.

Fixes #26337

* Fix isSpreadableProperty oversimplification
2018-10-29 14:51:12 -07:00
Anders Hejlsberg
24e3745296 Add regression test 2018-10-26 15:32:10 -07:00
Anders Hejlsberg
04fd365ec3
Merge pull request #27911 from Microsoft/fixCircularMappedType
Fix circular mapped type instantiations for arrays and tuples
2018-10-15 15:51:31 -07:00
Anders Hejlsberg
9767522ca0
Merge pull request #27695 from Microsoft/mixedDiscriminantTypes
Allow non-unit types in union discriminants
2018-10-15 13:10:27 -07:00
Anders Hejlsberg
0c3221c220 Add regression test 2018-10-15 10:24:00 -07:00
Sheetal Nandi
c0729a22fd Use string/number signature to get contextual type
Fixes #26587
2018-10-11 15:12:13 -07:00
Anders Hejlsberg
22907bfb07 Add tests 2018-10-10 15:40:12 -07:00
Anders Hejlsberg
209f30c2f1 Update test 2018-10-08 16:46:45 -07:00
Anders Hejlsberg
d4f480cbbb Add tests 2018-10-06 17:03:19 -07:00
Anders Hejlsberg
34994627f0 Add tests 2018-10-01 16:21:35 -07:00
Anders Hejlsberg
4bb5cfb9bb Add regression test 2018-09-25 18:17:21 -07:00
Ron Buckton
5fb39769ad
Merge pull request #27271 from Microsoft/fix24570-3
Fix iterated type in for-await-of
2018-09-21 12:28:18 -07:00
Ron Buckton
112fe6e2cc Fix iterated type in for-await-of 2018-09-21 10:40:45 -07:00
Ron Buckton
3a4d0b237f Add more tests for await 2018-09-21 10:32:28 -07:00
Ron Buckton
63adc5fb40 Add contextual typing for await operand 2018-09-21 10:32:18 -07:00
Ron Buckton
80dba4d63b Support promise-like types in contextual return type of async function 2018-09-21 10:32:00 -07:00
Anders Hejlsberg
eb06af1901 Add tests 2018-09-17 13:01:53 -07:00
Ryan Cavanaugh
6465e9dcdd
Merge pull request #26292 from Kingwl/tupleIndexAccessCheck
check index access for fixed length tuple
2018-09-05 12:10:46 -07:00
Nathan Shively-Sanders
c929e74310
Add [Constructor]Parameter types to lib.d.ts (#26243) 2018-08-31 07:46:16 -07:00
Nathan Shively-Sanders
cc3d011333
Infer this parameters (#26800)
Previously we didn't. I can't remember why, probably because I
overlooked it in the initial PR.
2018-08-31 07:45:34 -07:00
Nathan Shively-Sanders
b687caf3eb
No excess property error for spread properties (#26798)
That is, properties in an object literal type that came from a spread
assignment never cause an excess property error.
2018-08-30 16:16:58 -07:00
Anders Hejlsberg
c48c3632bd Update tests 2018-08-29 14:02:15 -07:00
Anders Hejlsberg
a2d2f5aee6 Merge branch 'master' into complexRestParameterTypes 2018-08-29 07:51:07 -07:00
Anders Hejlsberg
9f83958dbe Add tests 2018-08-27 16:06:17 -07:00
Anders Hejlsberg
676892ee56 Add tests 2018-08-25 07:55:13 -07:00
Nathan Shively-Sanders
0043ba16b1
Allow weak type detection for intersection sources (#26668)
Previously, intersections were only allowed as targets, but this was
just an artifact of the original implementation, which operated inside
the structural part of isRelatedTo. Removing this restriction catches
subtle bugs in React user code, where a function named `create` returns
a mapped type whose types are all branded numbers. The display of these
properties, for some original type `T`, is not `number & { __ }` but
the much-less-obvious `RegisteredStyle<T>`.
2018-08-24 10:30:39 -07:00
Anders Hejlsberg
74c57caa90 Add regression test 2018-08-22 07:16:31 -07:00
Anders Hejlsberg
596493cce4 Add tests 2018-08-17 10:11:28 -07:00
王文璐
6432bd9def check index access for fixed length tuple 2018-08-10 10:49:37 +08:00
Andy
639fdcc916
Don't include class getter in spread type (#26287)
* Don't include class getter in spread type

* Code review
2018-08-09 15:34:29 -07:00
Anders Hejlsberg
efdbbd1cf3 Add regression tests 2018-08-06 10:02:33 -07:00
Anders Hejlsberg
32a9ec6c30 Add tests 2018-07-29 15:25:54 -07:00
Anders Hejlsberg
1aa2b15f8c Add regression test 2018-07-25 12:42:47 -07:00
Anders Hejlsberg
dd4fd8c60e
Merge pull request #25913 from Microsoft/fixCircularConstraintCheck
Fix circular constraint check
2018-07-25 06:46:51 -07:00
Anders Hejlsberg
aeae05eaf5 Add regression test 2018-07-24 15:33:02 -07:00
Matt McCutchen
f72193eedc Report a semantic error for an arrow function with a "this" parameter.
Fixes #9744.
2018-07-23 10:42:56 -04:00
Anders Hejlsberg
5822a8c923 Merge branch 'master' into genericRestArityCheck
# Conflicts:
#	src/compiler/checker.ts
2018-07-12 08:20:48 -10:00
Anders Hejlsberg
55180f7725 Add tests 2018-07-12 07:07:13 -10:00
Nathan Shively-Sanders
42a2d9e568
Excess property understands conditional types (#25584)
Previously it did not, causing misleading excess property errors. Note
that assignability errors with conditional types are still usually
confusing. This PR doesn't address that.

Also, make sure that exact matches in getSpellingSuggestion are skipped.
2018-07-11 11:24:40 -07:00
Nathan Shively-Sanders
c228924543
Index signatures contribute properties to unions (#25307)
* Index signatures contribute properties to unions

This means that in a union like this:

```ts
type T = { foo: number } | { [s: string]: string }
```

`foo` is now a property of `T` with type `number | string`. Previously
it was not.

Two points of interest:

1. A readonly index signature makes the resulting union property readonly.
2. A numeric index signature only contributes number-named properties.

Fixes #21141

* Correctly handle numeric and symbol property names

1. Symbol-named properties don't contribute to unions.
2. Number-named properties should use the numeric index signature type,
if present, and fall back to the string index signature type, not the
other way round.
2018-07-06 10:46:05 -07:00
Anders Hejlsberg
e5d520e463 Add tests 2018-07-02 17:50:42 -10:00
Anders Hejlsberg
d869e56d33 Add tests 2018-06-25 10:45:38 -10:00
Anders Hejlsberg
9cd8eadfd2 Update tests 2018-06-24 14:32:50 -10:00
Anders Hejlsberg
0cc0fad381 Add tests 2018-06-14 13:06:37 -07:00
Mohamed Hegazy
35d25ff280
Merge pull request #24645 from Kingwl/this-type-accessibility
allow access protected member in this parameter context
2018-06-11 13:17:58 -07:00
王文璐
0bcbbbdd58 disallow static field access 2018-06-05 18:42:21 +08:00
王文璐
9767fbba09 allow access protected member in this parameter context 2018-06-04 15:16:59 +08:00
Anders Hejlsberg
54f9c17045 Add regression test 2018-06-03 11:59:24 -07:00
Anders Hejlsberg
577662de42 Update tests 2018-05-29 17:55:57 -07:00
Anders Hejlsberg
c694ffe7a5 Update tests 2018-05-29 12:54:12 -07:00
Anders Hejlsberg
31c73defa7 Update tests 2018-05-27 15:44:01 -07:00
Anders Hejlsberg
73af0adcf0 Add tests 2018-05-27 10:37:59 -07:00
Anders Hejlsberg
9d4096f9c4 Add tests 2018-05-21 16:43:55 -07:00
Anders Hejlsberg
238177657f Add regression test 2018-05-08 09:42:21 -07:00
Ron Buckton
f67afa098f Unpatch vfs resolver and default lib rename 2018-05-03 14:18:50 -07:00
Ron Buckton
d62a11ffc0 Merge branch 'master' into vfs 2018-05-01 18:58:31 -07:00
Anders Hejlsberg
4c933aef9a Check that test cases produce expected types 2018-05-01 13:05:49 -07:00
Anders Hejlsberg
59355cbfdb Add regression tests 2018-05-01 12:44:46 -07:00
Anders Hejlsberg
936444ad7b Add tests 2018-04-29 07:55:23 -07:00
Anders Hejlsberg
38d1f7f0d2 Add tests 2018-04-27 16:50:09 -07:00
Anders Hejlsberg
6c28da328e
Merge pull request #23672 from Microsoft/intersectionWithUnionConstraint
Type relationships for intersections with union constraints
2018-04-27 15:53:00 -07:00
Anders Hejlsberg
5ecd03e8c0
Merge pull request #23660 from Microsoft/fixIndexTypeTargetConstraint
Fix constraint of 'keyof T[K]' in target position
2018-04-27 15:52:21 -07:00
Nathan Shively-Sanders
3631af6486
Remove readonly from object rest properties (#23746)
* Remove readonly from object rest properties

Works the same as removing it from object spread properties

* Fix bug number in test
2018-04-27 14:54:59 -07:00
Ron Buckton
4863d55d01 Merge branch 'master' into vfs 2018-04-27 14:03:42 -07:00
Anders Hejlsberg
8442a45bb6 Add additional tests 2018-04-25 11:03:25 -07:00
Anders Hejlsberg
50c7ff79d0 Add tests 2018-04-24 15:57:17 -07:00
Anders Hejlsberg
ad4f83a281 Merge branch 'master' into fixIndexTypeTargetConstraint
# Conflicts:
#	tests/baselines/reference/keyofAndIndexedAccess.js
#	tests/baselines/reference/keyofAndIndexedAccess.symbols
#	tests/baselines/reference/keyofAndIndexedAccess.types
#	tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts
2018-04-24 11:08:08 -07:00
Anders Hejlsberg
57ef618120 Add regression test 2018-04-24 10:02:47 -07:00
Ron Buckton
bb26ab5556 Merge branch 'master' into vfs 2018-04-23 22:48:48 -07:00
Anders Hejlsberg
7befd35009 Add tests 2018-04-23 21:09:49 -07:00
Ron Buckton
1cbe930e06 Merge branch 'master' into vfs 2018-04-17 14:39:20 -07:00
Anders Hejlsberg
16cd5580a6 Merge branch 'master' into improveIndexTypes
# Conflicts:
#	src/compiler/checker.ts
#	src/server/utilities.ts
2018-04-16 16:18:29 -07:00
Anders Hejlsberg
0a37cd3736 Update test 2018-04-10 17:35:27 -10:00
Anders Hejlsberg
0379666bbf Update tests 2018-04-09 08:51:55 -10:00
Nathan Shively-Sanders
154ac342cb
Allow extending any, with noImplicitAny errors (#23153)
Allow extending any, without noImplicitAny errors
2018-04-05 08:52:56 -07:00
Anders Hejlsberg
6646717ce7
Merge pull request #23112 from Microsoft/fixTPReferenceLookups
Fix type parameter reference lookups
2018-04-03 12:32:05 -07:00
Anders Hejlsberg
cdf155e980 Add regression test 2018-04-03 09:04:36 -07:00
Nathan Shively-Sanders
11eabc0946
Skip parens and non-null assertions when looking for this-context (#23097)
* Skip parens and ! for getting this-context of call

* Add test and improve code a bit

* Use skipOuterExpressions instead
2018-04-03 06:23:59 -07:00
Anders Hejlsberg
751eab9eed
Merge pull request #23067 from Microsoft/fixTPReferenceInConditional
Fix type parameter reference checks in conditional types
2018-04-02 17:30:32 -07:00
Wesley Wigham
414bc49cc4
Module or import types (#22592)
* Type side of import types

* Value side of import types

* Accept library changes

* Refined implementation, more tests

* Allow resolutions to be performed late if the resolution still results in a file already in the build

* Add another test case

* Add some jsdoc usages

* Allow nodebuilder to use import types where appropriate

* Parse & check generic instantiations

* use import types in nodebuilder for typeof module symbols

* Wire up go to definition for import types

* Accept updated type/symbol baselines now that symbols are wired in

* PR feedback

* Fix changes from merge

* Walk back late import handling

* Remove unused diagnostic

* Remove unrelated changes

* Use recursive function over loop

* Emit type arguments

* undo unrelated change

* Test for and support import type nodes in bundled declaration emit
2018-04-02 10:18:23 -07:00
Anders Hejlsberg
ec02ccd575 Add regression test 2018-04-02 09:23:00 -07:00
Anders Hejlsberg
b3829523b2
Merge pull request #23039 from Microsoft/fixConditionalConstraints
Improve conditional type constraints
2018-03-31 11:56:05 -07:00
Anders Hejlsberg
b84e05e669 Add tests 2018-03-30 16:21:16 -07:00
Anders Hejlsberg
7714a2bb5b
Merge pull request #22989 from Microsoft/fixImpliedConstraint
Fix implied constraints in conditional types
2018-03-29 17:06:16 -07:00
Andy
a9aca81601
Error on for (const x in never) (#22988)
* Error on `for (const x in never)`

* Update diagnostic

* Provide argument to diagnostic
2018-03-29 11:39:30 -07:00
Anders Hejlsberg
bd442b7e52 Add regression test 2018-03-29 10:22:11 -07:00
Andy
65659d7297
Don't allow to iterate over 'never' (#22964)
* Don't allow to iterate over 'never'

* Include type in error message
2018-03-29 10:01:21 -07:00
Anders Hejlsberg
83276ce163 Add another test 2018-03-28 15:21:29 -07:00
Anders Hejlsberg
0e446fe8c2 Add regression test 2018-03-28 13:16:29 -07:00
Anders Hejlsberg
5b1554f708 Change test to use type variables 2018-03-25 15:30:46 -07:00
Anders Hejlsberg
8f860f672f Add tests 2018-03-25 11:33:24 -07:00
Anders Hejlsberg
7c0cc84abd Add tests 2018-03-25 11:30:08 -07:00
Anders Hejlsberg
e5f6ed0b60
Merge pull request #22707 from Microsoft/fixIndexedAccessInConditionalType
Fix indexed access in conditional type
2018-03-21 15:18:39 -07:00
Anders Hejlsberg
eb3fd150a7 Add regression test 2018-03-21 13:35:15 -07:00
Anders Hejlsberg
4fef35cdd0 Add regression test 2018-03-21 10:03:48 -07:00
Anders Hejlsberg
fa8564fa9e Add test to verify errors on nested 'infer T' declarations 2018-03-21 10:03:07 -07:00
Anders Hejlsberg
c94d28dbc8 Add test 2018-03-21 06:47:57 -07:00
Wesley Wigham
eaabf920eb
Combine keyof T inferences (#22525)
* Combine keyof T inferences

* Extract covariant inference derivation into function

* Test:keyof inference lower priority than return inference

for #22376

* Update 'expected' comment in keyofInferenceLowerPriorityThanReturn

* Update comment in test too, not just baselines

* Fix typo

* Move tests
2018-03-19 16:56:51 -07:00
Anders Hejlsberg
16f571b026 Add tests 2018-03-19 16:29:00 -07:00