Commit graph

143 commits

Author SHA1 Message Date
Wesley Wigham 5f597e69b2
Support naming tuple members (#38234)
* Initial draft of named tuple members

* Show tuple labels and documentation in completions

* Swap allowed syntax to parameter-like

* Add quickfix for labeled tuple syntax mistakes

* Add refactoring to convert list of signatures to single overload

* Fix small bug in visitor verification

* Signature help for rest parameters which are unions of tuples are displayed as seperate entries now

* Expand sanity check test cases in conformance suite

* Add tests and code for preserving tuple names through spreads where possible

* More refactoring tests, some comment preservation and some fixed formatting of multiline tuples

* Handle missing parameter named in isValidDeclarationForTupleLabel

* Minor text fixes
2020-05-19 15:54:02 -07:00
Wesley Wigham d9c9c9d9e4
Harden node builder APIs to no longer return undefined for a node when NodeBuilderFlags.IgnoreErrors is provided (#38273) 2020-05-04 14:47:39 -07:00
Alexander ceccfd8867 array-type: [ default: array, generic: array ] 2019-08-08 21:30:18 +03:00
Alexander 0059763d8f move eslint rules from eslint-plugin-microsoft-typescript to scripts/eslint 2019-07-24 13:31:17 +03:00
Alexander T f611ec68ed microsoft-typescript/no-double-space 2019-06-14 11:52:48 +03:00
Andrew Branch f97f57c155
Fix containsPrecedingToken for tokens whose preceding token is a missing node 2019-05-23 12:15:50 -07:00
Ron Buckton 3d2af9ff33
Relocate Debug namespace to reduce duplication (#31524) 2019-05-22 11:20:29 -07:00
Titian Cernicova-Dragomir d433042386 Fixed isVariadic handling when signature parameters are expanded for itemInfoForParameters 2019-03-11 02:55:10 +02:00
Titian Cernicova-Dragomir 88babf2a90 Merge remote-tracking branch 'remotes/origin/master' into GH-26563 2019-03-11 02:31:07 +02:00
Anders Hejlsberg 79813b8ece Show expanded parameter lists in signature help 2019-03-09 12:23:57 -08:00
Titian Cernicova-Dragomir 8d66d55de1 Improved argument description for parameters originating from tuples that were extracted from functions. (ie mapped functions) 2019-02-25 18:18:00 +02:00
Ron Buckton 76b78a4df5 Fix crash in signatureHelp 2019-01-22 15:02:30 -08:00
Sergio Baidon bb58558e64 Fix signature help not showing in block body bug 2018-09-18 17:30:07 -05:00
Nathan Shively-Sanders 6bd1da20c9
Rename JS-specific concepts (#26795)
* Rename JS concepts

1. Assignment declaration -- an assignment that is treated like a
declaration. Previously called [JS] special (assignment|declaration),
among other things.
2. Expando -- a value that can be used as a target in assignment
declarations. Currently, a class, function or empty object literal.
Functions are allowed in Typescript, too. Previously called a JS
container, JS initializer or expando object.
3. JavaScript -> Javascript. This is annoying to type, and looks like
'Java Script' in a camelCase world.

Everything is a pure rename as far as I know. The only test change is
the API baselines, which reflect the rename from SymbolFlags.JSContainer
to SymbolFlags.Assignment.

* Remove TODO

* Rename Javascript->JS

Note that this introduces a variable name collision in a couple of
places, which I resolved like this:

```ts
const isInJavascript = isInJSFile(node);
```
2018-09-12 10:44:46 -07:00
Nathan Shively-Sanders 540e8b9eb0
Collect jsdoc tags for type parameters (#26824)
Before the template tag, there was no reason to do this, but now you can
add JSDoc for type parameters in Typescript.
2018-09-04 09:29:19 -07:00
Andy 9106fdbc47
Support signature help for type parameters of a type (#26702) 2018-08-28 14:21:09 -07:00
Andy 937afab4b0
Support signature help for contextual parameter type (#26022) 2018-08-06 16:46:30 -07:00
Andy 0d1a49c865
Ignore trailing comma when resolving signature for quick info (#25841)
* Ignore trailing comma when resolving signature for quick info

* Add test for signature help
2018-07-31 11:39:39 -07:00
Andy 57d425169a
createJavaScriptSignatureHelpItems: Use array helpers and simplify (#26025) 2018-07-27 17:33:17 -07:00
Andy 998c911c49
Break createSignatureHelpItems into functions (#25948) 2018-07-26 17:26:29 -07:00
Andy 1e8a5bf2f1
signatureHelp: Factor out 'isSyntacticOwner' function (#25518) 2018-07-25 17:01:35 -07:00
Andy 52486ae362
Improve isPossiblyTypeArgumentPosition (#25043)
* Improve isPossiblyTypeArgumentPosition

* Update API (#24966)

* Handle new Type<Type<

* Add test for `new C < C<`
2018-07-11 11:15:04 -07:00
Daniel Rosenwasser 9481faab98 Only provide signature help contextually on a character trigger. 2018-07-03 17:08:32 -07:00
Daniel Rosenwasser 0fd587a3c3 Account for comments. 2018-07-03 13:02:14 -07:00
Daniel Rosenwasser 9651c4231e Account for trigger reasons, as implemented by Roslyn. 2018-07-02 16:04:48 -07:00
Daniel Rosenwasser 5e3c96bb9a Implemented support for trigger characters in signature help. 2018-06-12 15:48:40 -07:00
Wesley Wigham 6c78ce31ea
Set use flag (#24881) 2018-06-11 17:00:17 -07:00
Andy 675e21203e
Improve template literal tests (#24359)
* Improve template literal tests

* Inline isTemplateLiteralToken where possible
2018-05-30 10:21:00 -07:00
Andy fb4caadaec
Support signature help for partially-filled-in type arguments f< (#24138)
* Support signature help for partially-filled-in type arguments `f<`

* Use `isPossiblyTypeArgumentPosition` and support new expressions
2018-05-23 08:28:09 -07:00
Andy e53e56cf82
Enable '--strictNullChecks' (#22088)
* Enable '--strictNullChecks'

* Fix API baselines

* Make sys.getEnvironmentVariable non-nullable

* make properties optional instead of using `| undefined` in thier type

* reportDiagnostics should be required

* Declare firstAccessor as non-nullable

* Make `some` a type guard

* Fix `getEnvironmentVariable` definition in tests

* Pretend transformFlags are always defined

* Fix one more use of sys.getEnvironmentVariable

* `requiredResponse` accepts undefined, remove assertions

* Mark optional properties as optional instead of using `| undefined`

* Mark optional properties as optional instead of using ` | undefined`

* Remove unnecessary null assertions

* Put the bang on the declaration instead of every use

* Make `createMapFromTemplate` require a parameter

* Mark `EmitResult.emittedFiles` and `EmitResult.sourceMaps` as optional

* Plumb through undefined in emitLsit and EmitExpressionList

* `ElementAccessExpression.argumentExpression` can not be `undefined`

* Add overloads for `writeTokenText`

* Make `shouldWriteSeparatingLineTerminator` argument non-nullable

* Make `synthesizedNodeStartsOnNewLine` argument required

* `PropertyAssignment.initializer` cannot be undefined

* Use one `!` at declaration site instead of on every use site

* Capture host in a constant and avoid null assertions

* Remove few more unused assertions

* Update baselines

* Use parameter defaults

* Update baselines

* Fix lint

* Make Symbol#valueDeclaration and Symbol#declarations non-optional to reduce assertions

* Make Node#symbol and Type#symbol non-optional to reduce assertions

* Make `flags` non-nullable to reduce assertions

* Convert some asserts to type guards

* Make `isNonLocalAlias` a type guard

* Add overload for `getSymbolOfNode` for `Declaration`

* Some more `getSymbolOfNode` changes

* Push undefined suppression into `typeToTypeNodeHelper`

* `NodeBuilderContext.tracker` is never `undefined`

* use `Debug.assertDefined`

* Remove unnecessary tag

* Mark `LiteralType.freshType` and `LiteralTupe.regularType` as required
2018-05-22 14:46:57 -07:00
Wesley Wigham ec05f29632
Make signature help node building cancellable (#23543)
* Make token building cancellable

* Scope cancellation token, make find all refs and quickinfo cancellable

* Make completion entry details cancellable

* Actually accept public API update

* Add test verifying cancellations within checker for select language service operations

* Document runWithCancellationToken a bit more

* Add post-cancellation verification to test
2018-04-25 11:44:13 -07:00
Ryan Cavanaugh 9a5a5b10a3 Remove all reference comments from services 2018-04-11 15:39:12 -07:00
Andy b3edc8f9f4
Apply 'no-unnecessary-type-assertion' lint rule (#22005)
* Apply 'no-unnecessary-type-assertion' lint rule

* Fix type error

* Fix tsconfig.json

* Add --format back
2018-02-16 18:38:00 -08:00
Andy 69abe49930
Supports more locations for completions contextual types (#21946) 2018-02-16 16:48:03 -08:00
Wesley Wigham a33dae3771
Rework how default vs local name selection is done to be more correct (#21526) 2018-02-01 12:34:25 -08:00
Wesley Wigham 76d9524866
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter

* Unification of writers is done-ish

* Make node builder support more flags

* Write out mixins like we used to

* Accept prototype-free baselines

* Use instantiated constraint when building mapped type nodes

* Accept better mapped type baselines

* Report inaccessible this in node builder

* Turns out there was a bug in our codefix, too

* Symbol display builder usage falling

* Replace signatureToString with a nodeBuilder solution

* Replace the last internal usages of the symbol writer

* Accept semicolon additions

* Accept updated symbol baseline output

* Start using node builder for some LS operations

* Remove those pesky trailing semicolons on signatures

* Get signature printing much closer to old output

* Parameter lists should not be indented by default, especially when single-line

* Signatures up to snuff

* Type quickinfo emit is up to snuff

* Start of symbol writer replacement, needs a bit more for full compat

* Slightly mor accurate to old behavior

* Replicate qualified name type argument output correctly

* Bring back the old symbol baselines

* Mostly identical to old symbol emit now

* Perfectly matches old behavior thus far

* Replace another usage of the symbol builder

* Another usage removed

* Another usage removed

* Remove final uses of symbol display builder

* Remove implementation and types for unused symbol display builder

* Cleanup in the checker

* monomorphize new emitter code

* Replace emitWithSuffix

* Push space character to interface with writer

* List emit

* Fix lack of usage of emitExpression

* writeList, not printList

* Remove listy writes and replace with new printer calls

* Move ListFormat into types.ts

* Remove most new XToString functions in favor of node builder functions

* Accept API breaks

* Add getSymbolDisplayBuilder polyfill

* Accept updated API baseline

* Move definition to make diff easier to read

* Reinternalize some things

* Remove trailign whitespace

* Reorder for zero diff

* Remove newline

* Make shim mor eperfectly imitate old behavior

* Style feedback

* Rename reset to clear to maintain backcompat with SymbolWriter

* Fix quickfix

* Keep EmitTextWriter internal

* Remove EmitTextWriter from public API

* Mimic default name declaration emit fix

* Fix tests broken by merge

* use isFunctionLike

* Cleanup, sync TypeFormat and NodeBuilder flags

* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism

* Use variable instead of ternary

* Write helper for emitNodeWithWriter

* Emitter cleanup

* Cleanup whitespace, comment

* Reuse printer

* Raise error if display parts writer uses rawWrite

* Hide writer parameter through different function instead of overload, rename function in emitter

* Make less printer

* fix lint
2018-01-16 09:53:42 -08:00
Andy 6f2ba15446
Start linting for double spaces (#20820)
* Start linting for double spaces

* Code review

* Fix cases that were excluded by countDoubleSpaces

* Remove extraneous closing parenthesis
2018-01-08 08:52:13 -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
Anders Hejlsberg 601a21c77b Fix signature help 2017-09-02 15:39:14 -07:00
Anders Hejlsberg b65ff647c1 Improved caching scheme for anonymous types 2017-09-02 10:27:48 -07:00
Andy ceae613e4c Add lint rule to check that Debug.assert calls do not eagerly interpolate strings (#17125)
* And lint rule to check that `Debug.assert` calls do not eagerly interpolate strings

* Use more specific 'assert' functions to avoid callbacks

* Respond to PR feedback
2017-08-08 07:56:14 -07:00
Andy 30d973bdcb Rename symbol.name to escapedName and make name unescaped (#17412) 2017-07-25 14:22:26 -07:00
Andy eadd084c82 Add 'name' property to Identifier (#17329)
* Add 'name' property to Identifier

* Rename to unescapedText

* Rename 'id.text' to 'id.escapedText'

* Rename 'id.unescapedText' to 'id.text'

* Make escapeIdentifier and unescapeIdentifier do nothing
2017-07-25 13:16:34 -07:00
Andy 53e4040ceb Remove duplicate emptyArrays (#17305) 2017-07-20 06:45:22 -07:00
Wesley Wigham 4e6b2f3c93 Created a branded type for identifier-escaped strings (#16915)
* Created a branded type for escaped strings

Then flowed it throughout the compiler, finding and fixing a handful of
bugs relating to underscore-prefixed identifiers in the process.
Includes a test for two cases noticed - diagnostics from conflicting
symbols from export *'s, and enum with underscore prefixed member emit.

* Correctly double underscores WRT mapped types

* Add fourslash tests for other fixed issues

* use function call over cast

* Update forEachEntry type accuracy

* Just use escaped names for ActiveLabel

* Remove casts from getPropertyNameForPropertyNameNode

* This pattern has occurred a few times, could use a helper function.

* Remove duplicated helper

* Remove unneeded check, use helper

* Identifiers list is no longer escaped strings

* Extract repeated string-getting code into helper

* Rename type and associated functions

* Make getName() return UnderscoreEscapedString, add getUnescapedName()

* Add list of internal symbol names to escaped string type to cut back on casting

* Remove outdated comments

* Reassign interned values to nodes, just in case

* Swap to string enum

* Add deprecated aliases to escapeIdentifier and unescapeIdentifier

* Add temp var

* Remove unsafe casts

* Rename escaped string type as per @sandersn's suggestion, fix string enum usages

* Reorganize double underscore tests

* Remove jfreeman from TODO

* Remove unneeded parenthesis
2017-07-06 14:45:50 -07:00
Andy 18357543c6 Provide better services for incomplete generic calls (#16535)
* Provide better services for incomplete generic calls

* Use clearer name

* Remove `inferredAnyDefaultTypeArgument` and `getBestGuessSignature`; have `resolveSignature` always get the best signature if !produceDiagnostics

* Update names and comments
2017-06-27 09:14:23 -07:00
Andy Hanson 883ccaee5f Remove old commented-out code from signatureHelp 2017-05-08 11:30:09 -07:00
Andy Hanson 99c18744d2 Add isCallOrNewExpression helper 2017-05-03 10:57:57 -07:00
Arthur Ozga 7e03429a8e enforce triple-equals 2017-04-04 15:51:13 -07:00
Mine Starks af0b2d9768 Merge pull request #12856 from minestarks/includejsdoctags
Expose JSDoc tags through the language service
2017-03-31 17:58:41 -07:00