Commit Graph
100 Commits
Author SHA1 Message Date
Nathan Shively-Sanders a980d61f86 Add a few tuple tests and update baselines 2017-11-03 09:56:39 -07:00
Nathan Shively-Sanders d03d489cb3 Merge branch '6229-known-length-tuples' of https://github.com/tycho01/TypeScript into 6229-known-length-tuples 2017-11-03 09:10:44 -07:00
Nathan Shively-Sanders 75882db684 Merge branch 'master' into 6229-known-length-tuples 2017-11-03 09:07:38 -07:00
Nathan Shively-Sanders 8cfabcaeb4 Remove strictTuple flag and Tuple.length readonly 2017-11-02 10:07:47 -07:00
Nathan Shively-Sanders defd32f015 Move strict tuple test and add a couple of cases 2017-11-01 11:53:41 -07:00
Nathan Shively-Sanders 5d7e87a9c2 Add "strictTuples" to list of strict flags 2017-11-01 11:52:52 -07:00
Nathan Shively-Sanders b228736596 Merge branch 'master' into 6229-known-length-tuples 2017-11-01 11:51:49 -07:00
Nathan Shively-Sanders 146addc4d5 Use explicit undefined checkk 2017-11-01 10:35:54 -07:00
Nathan Shively-Sanders f4d4e89fa9 Merge branch 'master' into guard-name-in-getSuggestionForNonexistentSymbol 2017-11-01 10:34:19 -07:00
Nathan Shively-Sanders a6a5b85b52 Switch from undefined guard to asserts
In both fixSpelling and getSuggestionForNonexistentSymbol
2017-11-01 10:33:24 -07:00
Nathan Shively-Sanders e0e1a3b078 Test:this instantiation in type parameters
Make sure that `this` gets instantiated when it's used as a constraint
of a type parameter, and nowhere else in a signature.
2017-11-01 09:17:52 -07:00
Nathan Shively-Sanders db88c8eac2 Check function type parameters for this references
Previously, when checking for this references, the compiler did not
check type parameters. This caused it to miss some instantiations that
were necessary.

Also some cleanup:
1. Rename isIndependent* to is*FreeOfThisReference. 'Independent' was a
one-off concept that was unique to Typescript (and isn't referenced in
the spec), so I think the new name is friendlier to new readers.
2. Use `Array.every` whenever possible, since Typescript added a
dependency on ES5 since the code was first written.
3. Switch to JSDoc so that it shows up nicely in editors.
2017-11-01 09:12:01 -07:00
Nathan Shively-Sanders 98e9a561af Merge pull request #19219 from Microsoft/abstract-property-access-error-in-own-constructor-only
Abstract property access error in own constructor only
2017-10-31 13:27:24 -07:00
Nathan Shively-Sanders f26ac9f414 Merge pull request #19589 from Microsoft/reorder-jsdoctag-kinds
Fix the order of JSDocTag kinds
2017-10-30 16:07:28 -07:00
Nathan Shively-Sanders aea2ee5726 Fix the order of JSDocTag kinds
JSDocTypeLiteral should not be grouped with the JSDocTag kinds, so move
it just before they start, instead of just after. This updates the
LastJSDocNode and LastJSDocTagNode.
2017-10-30 15:00:34 -07:00
Nathan Shively-Sanders 505ffab745 Merge pull request #19511 from Microsoft/add-tsconfig-after-running-rwc
Generate tsconfig.json for RWC projects that lack them.
2017-10-30 10:54:27 -07:00
Nathan Shively-Sanders c5b199014c Use Harness.isDefaultLibraryFile to detect lib.d.ts 2017-10-30 10:20:11 -07:00
Nathan Shively-Sanders d2771a8e76 Improve regex for tsconfig test 2017-10-27 14:34:40 -07:00
Nathan Shively-Sanders 3ac91d109b Generate tsconfig in tsc-instrumented instead 2017-10-27 14:31:48 -07:00
Nathan Shively-Sanders 8ccf0af3ac Add tsconfig.json for RWC projects that lack them.
This should make all RWC projects browseable with an editor on Windows
(except two, see below). On Linux it still works pretty well if you
are willing to lowercase the imports of the file you're interested in.

Many RWC projects already have tsconfig.json files, but this change
creates one for projects that don't -- *after* running their respective RWC
test. That's because all the information is most easily available at
that time, and you probably won't need it until then anyway.

Note that two RWC projects use relative paths in their list of stored files
and don't work with this simple scheme. I'll look at that next, but if I
can't figure it out in the next hour or two, I'd prefer to merge this
since it's immediately useful for all the other projects.
2017-10-26 15:05:56 -07:00
Nathan Shively-Sanders 1ea1254e8e Merge pull request #19355 from Microsoft/sandersn/fix-getParameterSymbolFromJSDoc
fix getParameterSymbolFromJSDoc
2017-10-19 19:35:10 -07:00
Nathan Shively-Sanders 8cc2af59b1 More tests for getParameterSymbolFromJSDoc 2017-10-19 16:22:05 -07:00
Nathan Shively-Sanders 97a6f14ca2 Consolidate jsdoc node getters
They are now used both in getJSDocCommentsAndTagsWorker and in
geParameterSymbolFromJSDoc.
2017-10-19 14:12:56 -07:00
Nathan Shively-Sanders c2bbfafcbe Fix getParameterSymbolFromJSDoc 2017-10-19 09:13:31 -07:00
Nathan Shively-Sanders ecdc4b363e Test:jsdoc @param errors on vardecls/assignments 2017-10-19 09:12:49 -07:00
Nathan Shively-Sanders d8373c3dbb Merge pull request #19314 from Microsoft/fix-tsc-instrumented
Fix four tsc-instrumented bugs
2017-10-18 16:41:40 -07:00
Nathan Shively-Sanders 79c672424e Fix lint 2017-10-18 15:32:24 -07:00
Nathan Shively-Sanders 93c2b10f68 Fix tsc-instrumented
1. Make recursiveCreateDirectory correctly handle relative paths.
2. Remove dependency on Harness
3. Correctly increment iocapture0, iocapture1, ... iocaptureN.
4. Stop double-nesting baseline files.
2017-10-18 15:29:11 -07:00
Nathan Shively-Sanders b40e18df00 Merge pull request #19304 from Microsoft/dedupe-jsdoc-annotation-refactors
Fixes for refactor "Annotate with type from JSDoc"
2017-10-18 14:50:13 -07:00
Nathan Shively-Sanders f82dd7b1da Move isJSDocIndexSignature to utilities 2017-10-18 13:16:22 -07:00
Nathan Shively-Sanders aa73ed8226 Fix bugs in jsdoc annotation refactor
1. Transform index signatures to TS index signatures.
2. Print object literals on a single line.
3. Only offer the refactor when it could add types. (There must not be a
type annotation already, and there must be a JSDoc that applies.)
2017-10-18 13:07:54 -07:00
Nathan Shively-Sanders 2473ffcaac Add a better test for jsdoc index signatures.
The test case shows that the errorenous error no longer appears.
2017-10-18 13:06:15 -07:00
Nathan Shively-Sanders c13506e70c Update annotateWithTypeFromJSDoc tests
1. Object literals are single-line now.
2. Index signatures transform to TS index signatures.
3. The refactoring is only available when it could add types.
2017-10-18 13:04:13 -07:00
Nathan Shively-Sanders f374117858 Remove erroneous error for JSDoc object literals
appears with checkJS.
2017-10-18 11:32:48 -07:00
Nathan Shively-Sanders e962e4abfb Update baselines 2017-10-17 16:35:28 -07:00
Nathan Shively-Sanders 64fc495234 Collapse jsdoc annotation refactors to one
Previously there were two, and two always fired.
2017-10-17 16:33:52 -07:00
Nathan Shively-Sanders 487504da46 Merge pull request #19250 from Microsoft/mark-fresh-spread-types-with-ContainsObjectLiteral
Mark fresh spread types with ContainsObjectLiteral
2017-10-17 11:01:34 -07:00
Nathan Shively-Sanders abdfbaa067 Fix lint 2017-10-17 09:59:32 -07:00
Nathan Shively-Sanders e58aa10068 Test excess property checks of spreads of unions. 2017-10-17 09:56:28 -07:00
Nathan Shively-Sanders 08d7e182cd Mark fresh spread objects w/ContainsObjectLiteral 2017-10-17 09:56:04 -07:00
Nathan Shively-Sanders cd1be1bbe3 Test:type inference from strings to keyof T succeeds 2017-10-16 13:35:12 -07:00
Nathan Shively-Sanders cfd97da680 Infer keyof from string literals + contravariantly
1. When inferring from a string literal [union] type to a index type,
infer a object type with properties whose names match the constituents of the
union type. The type of all the properties is `{}`.
2. Infer index types contravariantly.

For example, when inferring `"foo" | "bar"` to `keyof T`, the inference
algorithm now infers `{ foo: {}, bar: {} }` to `T`. When inferring
`string` to `keyof T`, the inference algorithm now infers `{ [s:
string]: {} }` to `T`.
2017-10-16 13:31:23 -07:00
Nathan Shively-Sanders 49beac919c Abstract property access error only on this access 2017-10-16 09:43:49 -07:00
Nathan Shively-Sanders fb45b49afc Test:abstract prop access in non-declaring ctor 2017-10-16 09:20:28 -07:00
Nathan Shively-Sanders 5e7bfad2a7 Check own-constructor in abstract prop access error 2017-10-16 09:19:46 -07:00
Nathan Shively-Sanders 22769d95e1 Merge pull request #18747 from Microsoft/refactor-jsdoc-types-to-typescript
Refactor jsdoc types to typescript
2017-10-13 10:21:54 -07:00
Nathan Shively-Sanders 4cf06bbb02 Fix spacing lint 2017-10-13 10:02:04 -07:00
Nathan Shively-Sanders 84e3507151 return more Debug.fails instead of undefined. 2017-10-13 09:45:41 -07:00
Nathan Shively-Sanders c83daa6481 JSDoc->type refactor:Renames+improve never handling 2017-10-13 09:38:01 -07:00
Nathan Shively-Sanders f35764d4ec Fix duplicated JSDoc comments
Incorporate suppressLeadingAndTrailingTrivia just added by @amcasey.
2017-10-12 14:28:34 -07:00
Nathan Shively-Sanders c2c18a8d06 Merge branch 'master' into refactor-jsdoc-types-to-typescript 2017-10-12 14:18:28 -07:00
Nathan Shively-Sanders b440d75bc4 Test refactor of JSDoc @template tag 2017-10-12 11:40:40 -07:00
Nathan Shively-Sanders 123347d5c4 Convert @template tag to type parameters in refactor 2017-10-12 11:40:07 -07:00
Nathan Shively-Sanders 54ad9a6c82 Merge pull request #19112 from Microsoft/fill-missing-type-arguments-during-error-reporting
Fill missing type arguments during error reporting
2017-10-12 11:02:25 -07:00
Nathan Shively-Sanders 27b4417304 Assert:checkTypeArguments isn't passed too many type arguments 2017-10-12 10:38:02 -07:00
Nathan Shively-Sanders 8ea13bef48 Fix lint 2017-10-12 10:11:09 -07:00
Nathan Shively-Sanders da0c79f2a3 Simplify checkTypeArguments based on PR comments 2017-10-12 10:09:52 -07:00
Nathan Shively-Sanders d00ab417c6 checkTypeParameters now always calls fillMissingTypeArguments
And refactor checkTypeParameters to be easier to use and to read.
2017-10-11 15:58:54 -07:00
Nathan Shively-Sanders 156e7e2069 Test:Incorrect number of type args during err reporting 2017-10-11 14:02:20 -07:00
Nathan Shively-Sanders 3fef16008d Fill missing type arguments during error reporting
Previously, only the success path did this; it was missing in the error
reporting path in resolveCall. This resulted in crashes for unsupplied
type arguments when the supplied type arguments were incorrect.
2017-10-11 14:01:25 -07:00
Nathan Shively-Sanders d7424b00b2 Merge branch 'master' into refactor-jsdoc-types-to-typescript 2017-10-11 13:41:45 -07:00
Nathan Shively-Sanders 1a1c1f9e93 Add and update jsdoc annotation refactoring tests 2017-10-11 13:34:16 -07:00
Nathan Shively-Sanders 4930cad653 Convert all JSDoc parameters and return types of functions 2017-10-11 13:33:31 -07:00
Nathan Shively-Sanders 461e29bbd8 Merge pull request #18965 from Microsoft/set-symbol-on-union-of-spreads
Set symbol on union that is returned from `getSpreadType`
2017-10-11 13:25:45 -07:00
Nathan Shively-Sanders de68f067d5 Set flags on fresh object types from getSpreadType
Previously, getSpreadType didn't set any flags and relied on its callers
to do so. This was error-prone because getSpreadType often returns
non-fresh types.
2017-10-11 08:17:40 -07:00
Nathan Shively-Sanders 9b51c33582 Merge pull request #19005 from charlespierce/abstract_property_in_constructor
Error when accessing abstract property in constructor #9230
2017-10-09 13:21:33 -07:00
Nathan Shively-Sanders 517dbf3ca7 Fix semicolon lint 2017-10-09 11:14:24 -07:00
Nathan Shively-Sanders 405d8cf8eb In getSuggestionForNonexistentSymbol, guard name against undefined 2017-10-09 10:45:50 -07:00
Nathan Shively-Sanders afa4842b2a Merge pull request #16363 from Microsoft/excess-property-checks-for-discriminated-unions
Excess property checks for discriminated unions
2017-10-06 10:54:04 -07:00
Nathan Shively-Sanders e1bc916b91 Merge branch 'master' into excess-property-checks-for-discriminated-unions 2017-10-06 09:18:57 -07:00
Nathan Shively-Sanders 97ee9516d6 Update baselines 2017-10-05 09:10:55 -07:00
Nathan Shively-Sanders da6acba71e Merge branch 'master' into excess-property-checks-for-discriminated-unions 2017-10-05 09:07:23 -07:00
Nathan Shively-Sanders 0cb12b32a5 Test:{} in union from spread gets implicit index signature
Also tighten up the existing test code in the file.
2017-10-05 09:03:03 -07:00
Nathan Shively-Sanders b69652b137 Set symbol on union of spreads
Previously, it was only set on the top-level type, and only if that
top-level type was an object type. Now it uses `forEachType` to set the
symbol on every object type in the union as well, if `getSpreadType`
returns a union.
2017-10-05 09:01:39 -07:00
Nathan Shively-Sanders 8b2a219dd4 Merge pull request #18955 from Microsoft/binding-element-with-parent-type-any-is-any
Binding element with parent type any is of type any
2017-10-04 16:03:44 -07:00
Nathan Shively-Sanders 2ae70a1c2b Update baselines 2017-10-04 15:24:23 -07:00
Nathan Shively-Sanders da41217f43 Binding element with parent type any is any
Previously if the binding element had an initializer, then that type
would be used. But this is incorrect:

```ts
function f(x: any) {
  let { d = 1 } = x;
  // d should have type any not number.
  // f can be called with anything:
}
f({ d: 0 });
f({ d: 'hi' });
f({});
```
2017-10-04 15:15:29 -07:00
Nathan Shively-Sanders 02e7835bbd Merge branch 'master' into fix-spread-contextually-typed-by-binding-pattern 2017-10-03 12:43:59 -07:00
Nathan Shively-Sanders 2c04b5510f Test:spread contextually typed by binding pattern 2017-10-03 12:43:23 -07:00
Nathan Shively-Sanders 7b0e74d91a Binding pattern contextual type checks spread type
The spread type can contain properties that have been built up during
the construction of the object literal.
2017-10-03 12:41:33 -07:00
Nathan Shively-Sanders 4d8663c378 Merge pull request #18117 from Microsoft/jsdoc-dotdotdot-binds-tighter-than-postfix
Jsdoc ... binds tighter than postfix ?!
2017-10-03 08:45:26 -07:00
Nathan Shively-Sanders 6831e65235 Merge branch 'master' into refactor-jsdoc-types-to-typescript 2017-10-02 16:24:00 -07:00
Nathan Shively-Sanders d797b4ab76 Correctly transform jsdoc parameter types
And give a better name for rest params
2017-09-28 11:40:56 -07:00
Nathan Shively-Sanders 724a813105 Merge branch 'master' into refactor-jsdoc-types-to-typescript 2017-09-28 09:17:28 -07:00
Nathan Shively-Sanders fc933d7c33 Transform jsdoc types in the refactor, not emitter
The emitter now understands JSDoc types but emits them in the original
format.
2017-09-26 12:42:08 -07:00
Nathan Shively-Sanders 96b8093890 Move filenames to match refactoring rename 2017-09-26 09:08:39 -07:00
Nathan Shively-Sanders 13b37a4825 Change refactoring name and description 2017-09-26 08:58:18 -07:00
Nathan Shively-Sanders 8996d11096 Test:refactor JSDoc types to Typescript types 2017-09-25 09:02:42 -07:00
Nathan Shively-Sanders 6d218e2a48 Refactor JSDoc types to Typescript types
When the caret is on a Typescript declaration that has no type, but does
have a JSDoc annotation with a type, this refactor will add the
Typescript equivalent of the JSDoc type.

Notes:

1. This doesn't delete the JSDoc comment or delete parts of it. In fact,
due to bugs in trivia handling, it sometimes duplicates the comment.
These bugs are tracked in #18626.

2. As a bonus, when `noImplicitAny: true`, this shows up as a code fix in VS Code
whenever there is a no-implicit-any error. With `noImplicityAny: false`,
this code must be invoked via the refactoring command.
2017-09-25 08:56:51 -07:00
Nathan Shively-Sanders 36cdbb2857 Merge pull request #18625 from Microsoft/fix-getAdjustedStartPosition-on-first-line
Fix get adjusted start position on first line
2017-09-21 10:08:30 -07:00
Nathan Shively-Sanders 3cc0aeb6be PR comments
I plan to fix the missing comment issue when I add the
convert-jsdoc-types-to-typescript-types refactoring. Or at least work
around it.
2017-09-21 09:44:51 -07:00
Nathan Shively-Sanders 410f84656d Update baselines temporarily
The loss of comments is not good, but should be fixed when
(1) trivia-handling issues are fixed or (2) the reafactorings themselves
add a workaround.
2017-09-20 16:31:28 -07:00
Nathan Shively-Sanders ae87db7b3e getAdjustedStartPosition shouldn't skip to next line when on 1st line 2017-09-20 16:26:46 -07:00
Nathan Shively-Sanders 406d9abb5a Merge pull request #18264 from Microsoft/make-jsdoc-getters-public
Make top-level getJSDoc* functions public
2017-09-19 11:33:45 -07:00
Nathan Shively-Sanders 339a7e5f63 Merge branch 'master' into make-jsdoc-getters-public 2017-09-19 11:20:06 -07:00
Nathan Shively-Sanders cc678a5184 Merge pull request #18440 from Microsoft/fix-javascript-signature-instantiation
Fix javascript signature instantiation
2017-09-19 08:43:16 -07:00
Nathan Shively-Sanders 088da79079 Merge pull request #18451 from Microsoft/allow-booleans-in-spreads
Allow `falsy | T` spreads for falsy primitives
2017-09-15 16:24:16 -07:00
Nathan Shively-Sanders cb8d9d6143 Revert spread-falsy-union/fix spread of primitive
Turns out partialising falsy unions wasn't needed -- I was just
returning the wrong thing when spreading primitives.
2017-09-15 16:11:41 -07:00
Nathan Shively-Sanders 0197357e31 Remove mistakenly added test file
Intended for a different PR
2017-09-15 10:28:13 -07:00
Nathan Shively-Sanders 7497d4cb3a Merge branch 'master' into allow-booleans-in-spreads 2017-09-15 10:26:57 -07:00