* ensure export modifier is used before default modifier
* gracefully handle `default function`
* Revert "gracefully handle `default function`"
This reverts commit 1d8e288754.
* give better error message on default without leading export
* Check entire access path is constant when narrowing by inlining
* Add tests
* Accept new baselines
* Added test cases for parameter properties.
* Accepted baselines.
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
* Issue unawaited promise error on symbol-less expressions
* Use same behavior for call expressions
* Revert "Use same behavior for call expressions"
This reverts commit 60d58132e4.
* CFA inlining of conditional expressions referenced by const variables
* Accept new baselines
* Add tests
* Accept new baselines
* Increase inlining limit to 5 levels per design meeting discussion
* Class static block (#9)
* Add types factory and parser
* Add some case
* Make class static block as a container
* Update cases
* Add visitor
* Add emitter and more compile target
* Check boundary of break and continue
* Add basic transformer
* Fix emit behavior
* Add more tests
* Add friend tests
* Update baseline
* Fix cr issues
* Accept baseline
* Add decorator and modifier check
* Add functional boundary check
* Fix conflict
* Fix computed prop name within context
* Add more tests
* Update baseline
* Avoid invalid test baseline
* Support use before initialize check
* wip
* Fix class static block context
* Fix checks
* Fix missing case
* Improve assert message
* Accept baseline
* Avoid new context
* Update diagnostic message
* Fix name collision
* Fix targets
* Avoid unnecessary files
* Add more case
* Add more test cases
* Fix strict mode function declaration
* Avoid private fields initializer if no private identifier references
* Avoid private fields and add more test case
* Add more case
* Add tests and support for related services functionality
* Fix this reference in static block
* Split parser diagnostic and binder diagnostic
Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
* Add signature arguments label support
* Support rest parameters and destruction
* make lint
* Fix tuple rest parameters
* Adjust name styles
* Rename to inline hints
* Partition inline hints
* Adjust range pred
* Add function expression like hints
* Support configure inline hints
* Display hints in single line
* Add test suits and tests
* Add range tests
* Support more hints
* Add more options
* Fix logical
* Add more cases
* Support call chains
* Rename options
* Match lastest protocol
* Update protocol changes
* Support context value and hover message
* Revert "Support context value and hover message"
This reverts commit 37a7089633.
* Revert "Update protocol changes"
This reverts commit e5ca31bc30.
* Add hover message
* Accept baseline
* Update src/services/inlineHints.ts
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
* Update src/services/inlineHints.ts
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
* Cache across the program
* Fix possible undefined
* Update protocol changes
* Fix missing property
* Make lint happy
* Avoid call chain hints
* I'm bad
* Add whitespace before type
* Add more tests
* Should care about jsdoc
* Support complex rest parameter
* Avoid module symbol hints
* Care about leading comments
* Fix CR issues
* Avoid changes
* Simplify comments contains
* Fix CR issues
* Accept baseline
* Check parameter name before create regex
* Rename option
* Avoid makers
* Skip parens for argument
* Fix CR issues
* Fix enums
* Accept baseline
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
* Fix 'arguments' check in class field initializer or static initialization block
* return errorType
* Merge branch 'master' of https://github.com/exoticknight/TypeScript
* use isInPropertyInitializer
fix Diagnostics message
* Switch index signature storage to 'indexInfos: IndexInfo[]' property
* Accept new baselines
* Remove another usage of IndexKind enum
* Update getIndexedAccessType and resolveMappedTypeMembers
* Accept new baselines
* Update grammar checking for index signatures
* Accept new baselines
* Consider all index signatures in mapped types and union types
* Accept new baselines
* Update getIndexType
* Accept new baselines
* Intersect multiple applicable index signatures
* Use getApplicableIndexInfo instead of hardwired string/number handling
* Update index signature relationship checking
* Report type for which index signature is missing
* Report type for which index signature is missing
* Accept new baselines
* Make 'number' index signatures consistently apply to numeric strings
* Accept new baselines
* Update fourslash test
* Revise index constraint checking
* Accept new baselines
* Update error messages
* Accept new baselines
* Update type inference from index signatures
* Update isKnownProperty
* Update contextual typing based on index signatures
* Accept new baselines
* Support union types in index signature declarations
* Accept new baselines
* Check duplicate index signatures / remove redundant template literals from unions with string
* Accept new baselines
* Include key type in diagnostic / check symbol-named properties
* Accept new baselines
* Minor fix
* Add tests
* Accept new baselines
* Add optimized findApplicableIndexInfoForName
* Accept new baselines
* Another place we don't need to obtain literal type for property name
* Accept new baselines
* Don't create literal types that are going to be discarded
* Individual maps for string, number, bigint, and enum literal types
* Remove ineffective optimizations
* Accept new baselines
* Permit intersections as key types in index signatures
* Index expression in element access is template literal context
* Add tests
* Accept new baselines
* Symbol index signatures from object literals with computed symbol properties
* Accept new baselines
* Add more tests
* Accept new baselines
* Implement Go To Definition for all applicable index signatures
* Add fourslash test
* Accept new API baselines
* Don't attach declarations to symbols in mapped types with 'as XXX' clauses
* Add test (and tweak comment)
Co-authored-by: Eli Barzilay <eli@barzilay.org>
* Always issue cannot find name did-you-mean error
This PR issues "cannot find ${name}, did you mean ${name}" errors for
identifiers and propery access expressions in JS files *without*
`// @ts-check` and without `// @ts-nocheck`. This brings some benefits of
Typescript's binder to all Javascript users, even those who haven't
opted into Typescript checking.
```js
export var inModule = 1
inmodule.toFixed() // errors on exports
function f() {
var locals = 2
locale.toFixed() // errors on locals
}
var object = {
spaaace: 3
}
object.spaaaace // error on read
object.spaace = 2 // error on write
object.fresh = 12 // OK, no spelling correction to offer
```
To disable the errors, add `// @ts-nocheck` to the file. To get the
normal checkJs experience, add `// @ts-check`.
== Why This Works ==
In a word: precision. This change has low recall — it misses lots
of correct errors that would be nice to show — but it has high
precision: almost all the errors it shows are correct. And they come
with a suggested correction.
Here are the ingredients:
1. For unchecked JS files, the compiler suppresses all errors except
two did-you-mean name resolution errors.
2. Did-you-mean spelling correction is already tuned for high
precision/low recall, and doesn't show many bogus errors even in JS.
3. For identifiers, the error is suppressed for suggestions from global files.
These are often DOM feature detection, for example.
4. For property accesses, the error is suppressed for suggestions from
other files, for the same reason.
5. For property accesses, the error is suppressed for `this` property
accesses because the compiler doesn't understand JS constructor
functions well enough.
In particular, it doesn't understand any inheritance patterns.
== Work Remaining ==
1. Code cleanup.
2. Fix a couple of failures in existing tests.
3. Suppress errors on property access suggestions from large objects.
4. Combine (3) and (4) above to suppress errors on suggestions from other, global files.
5. A little more testing on random files to make sure that precision
is good there too.
6. Have people from the regular Code editor meeting test the code and
suggest ideas.
* all (most?) tests pass
* NOW they all pass
* add tonnes of semi-colons
* restore this.x check+add a test case
* make ts-ignore/no-check codefix work in unchecked js
* Issues errors only in the language service
* add a few more tests
* fix incorrect parentheses
* More cleanup in program.ts
* Improve readability of isExcludedJSError
* make diff in program.ts smaller via closure
* Switch unchecked JS did-you-mean to suggestion
Instead of selectively letting errors through.
* undo more missed changes
* disallow ignoring suggestions
* Issue different messages for plain JS than others
Straw text for the messages, I just changed the modals to avoid name
collisions.
* Fix discovery of more pnpm symlinks
* Add some tests
* Never show pnpm paths in auto imports, even if there’s no other path
* Import statement completions can return none
* Fix tests
* Add failing test showing poor symlink cache reuse
* Fix test, fails for right reasons now
* Preserve cache built up during program creation, then fill in with program resolutions
* Remove obsolete comment
* Remove obsolete type assertion
* Revert fully filtering out ignored paths
* Add test case for 'useUnknownInCatchVariables'.
* Add new 'useUnknownInCatchVariables' flag.
* Accepted baselines.
* Add test for catch variable explicitly typed as 'any'.
* Accepted baselines.
* Move option under 'strict'.
* Accepted baselines.
* 'useUnknownInCatchVariables' is strict in command line help.
* Add unqualified JSDoc member references
This allows unqualified references like:
```ts
class Zero {
/** @param buddy Must be {@link D_HORSE} or {@link D_DOG}. */
deploy(buddy: number) { }
static D_HORSE = 1
static D_DOG = 2
}
```
I surveyed @see and @link again to estimate how common this is. I found
a little over 200 uses, which is around 2%. Sorted by frequency, this
*is* the next feature on the list, along with the `module:` prefix.
So I think this is about the right point to stop adding code.
In this case, however, I liked most of the uses -- there were a lot
of deprecated functions that referenced a function just below, where it
would be wordy to qualify the name, but the reader would benefit from a
link.
Note that unqualified references do *not* work inside type or object
literals. The code I ended up with is quite complicated and I didn't
observe any uses in the wild.
Fixes#43595
* Remove type/object literal container check
Since they don't work anyway
* Ensure static index signatures have an errorNode available
* Lookup static index signature declarations in the right symbol table, stop checking prototype props
* Add @linkcode and @linkplain tags
They are just like @link tags but request fixed-width and normal
presentation, respectively.
Fixes#43935
* revert JSDocComment -> JSDoc SyntaxKind rename
* update API baselines
* fix lint
* support QualifiedName when narrowing inside loops
* add test
* narrow more qualified names
* handle `undefined` of `getFlowCacheKey `
* update comments in test
* Everything mostly works
A couple of mixed, nested references don't work yet.
The scanner+parser interaction is wrong, the parser consumes one too
many spaces, and the checker+services code needs a little cleanup.
* Cleanup
1. I decided that correctly parsing a#b.c, an entity name containing an
instance reference, is not worth the work.
2. I made the scanner, at least the jsdoc part, emit a # token, and
provided a reScanPrivateIdentifier in order to convert #a to # a.
3. I cleaned up the code in the checker.
2. Unrelated: I added a missing space in linkPart display.
* Cleanup lint + var naming
* investigate+clean up a couple of TODOs
* Fix lint in utilities.ts
* change name to JSDocMemberName
* address PR comments
* Cache accessibe symbol chains, type parameter name generation
* Move signature declaration helper length approximation to start of function
* Add node result caching internal to `typeToTypeNodeHelper`
* Suggestion from PR
* Improve errors for incorrectly nested export default
The compiler and services don't handle incorrectly nested
`export default` well right now:
```ts
export = (x,y) => {
export default { }
}
```
Asking for document highlights, find all references or quick info on
'export' or 'default' cause a crash. After the crash is fixed, the error
message is confusing and wrong: "An export assignment cannot be used outside a module."
This PR:
1. Skips document highlights for incorrectly nested export default.
2. Skips find all refs for incorrectly nested export default.
3. Switches the fallback binding for incorrectly nested export default
from Alias to Property. Neither is correct, but Property doesn't cause a
crash in alias resolution.
4. Improves the error message to reflect a post-ES module world, which
has export default and 'module' means 'ES module', not 'namespace'.
Fixes#40082 and the related bugs mentioned above.
* address PR comments
PR #42556 was a nice optimization that dramatically sped up comparisons of discriminated unions. Unfortunately, the cost of determining whether a union is discriminated can be prohibitively high. In particular, an internal team with a very large repo saw their type count double and their memory usage increase from 6GB to 9GB, breaking their build. This changes splits the difference by not trying to compute the property types of intersection types - a notoriously slow operation.
* Allow filterType to consider union constraints of non-union types when determining never-ness
* Move impl to callback
* Baseline change in narrowing behavior into test, fix post-LKG build
* Test where relative import isnt ideal in the declaration emit
* use project relative preference for declaration emit
Fixes#39117
* Fix incorrect path matching when calculating module specifier
* Use correct baseUrl for the module specifier
Previously, getExternalModuleMember passed through its received value of
`dontResolveAlias` to every function that accepted it. That includes (1)
resolution of the module symbol and (2) resolution of the module
specifier. However, in TS, the module symbol is never an alias anyway, so
dontResolveAlias doesn't make a difference. In JS, the module symbol
*can* be an alias, and it should always be resolved. That's what this PR
does.
Fixes#43713
* Scribbles + tests
The second test actually requires node types
* Basically working
The two simple fixes, in arity error reporting, are in, and the
simplification of arity error reporting is half-done. I haven't started
on any improvements to call assignability.
* trim out too-real test case
* Finish cleanup
And reword error a little.
* Simplify and reword spread errors
* handle spreads first
* update baselines
* Address PR comments
* Allow `override` as parameter property
* Update other baseline
* Add test for override on normal parameter
* Copy typo fix
* Update baselines
* Update API baseline
* Relate non-augmenting array subtypes without resorting to structural comparison
* Fix lint
* Generalize performance enhancement
* Cache results, feed through via getNormalizedType to remove error intermediates
* Use newly freed up object flags to limit member setting, fix crash with those object flags
* Move flags because there is no TypeFlags.Reference 🤦
* Fix completions of exports elsewhere in same file
* Undo messing up JSDoc-annotated module.exports assignments
* Add other failing contextual type test
* Rearrange contextual type logic for special assignments
* Rename helper function
This diff extends the types checked by
discriminateContextualTypeByObjectMembers and
discriminateContextualTypeByJSXAttributes to also include any optional
components in the type union.
fixes#41759 although it doesn't address the better error reporting for
their last repro, which I'm not sure how to address.
* Completion list for type literals in type arguments
* Add tests
* Refactor for better readability
* - Support non-identifier keys
- Move main logic onto tryGetGlobalSymbols function
* Instantiate getter when infering setter parameter value
* Use esnext on tests
* Instantiate for JsDoc and getter from body
* PR comments
* Updated baseline
* Use faster, stricter prop type comparison when merging props in union prop creation
* Be better at determining this usage in methods, accept baselines
* Small style change
* Consider identical instances of the same symbol equivalent when creating union and intersection properties
* Also copy over mapper and type (if available) on cloned symbols
* Editorial feedback
* Test + Initial scribbles
The test is pretty good, the scribbles are actually cleanup from last
PR, although they break some tests.
* undo scribbles, add nonworking class-hack
* Ad-hoc name resolution for @link and @see
Turns out that you can't reuse check* functions if you want to retrieve
all meanings of a reference.
* fix failing test
* inline hapax function
* Fix find-all-refs baseline print
* Try to resolve C.m as static first
* Add interface tests
Co-authored-by: Andrew Branch <andrew@wheream.io>
* Ignore object types in intersections with primitive types
* Add regression test
* Also handle instantiable types constrained to object types
* Add another test
* Add ignoreObjects optional parameter to getTypeFacts
* If target:esnext,then useDefineForClassFields: true will now be the default.
* Added error if a private identifier is used in a static a initializer if target:ESNext and useDefineForClassFields:false.
* Added test for new useDefineForClassFields default and error message.
* Fixed tests after changing the default of useDefineForClassFields to true for target esnext
* Fixed code review suggestions.
* Updated error message.
* Added missing static check for the containing property. Fixed other code review issues.
* Allow redeclaring CommonJS alias with initial undefined
This allows us to read our own output, plus the times when people
manually write exactly the same pattern.
Fixes#40555
* Use control flow to type commonjs exports
1. Could probably use a *lot* more tests.
2. getTypeOfAlias redoes some work from resolveAlias because it needs to
not resolve the alias completely, just to its export.
* fix lint, improve jsdoc
* Add tests, improve+fix control flow
1. Update the module.exports test to match the exports ones.
2. Add a test of evolving commonjs type.
3. Add a test of assignment as last statement.
(1) exposed a bug that required a better synthetic reference. (3)
exposed a bug that was most easily fixed by giving source files a
`endFlowNode` like functions and setting it in the binder.
* fix lint
* Fix getRecursionIdentity, undo changes from #43435 (but keep tests)
* Remove test that takes excessively long to run
* Accept new baselines
* Fix formatting
* Add regression tests
* Reinstate test
* Do not covariantly mix in constraints from contravarrying positions
* Exclude keyof from constraint variance tracking
* Extra test case
* Always subtitute on type parameter types
* WIP
* WIP
* Get completion details working
* Start unifying eager and lazy auto imports
* Fix export=
* Fix completion details for totally misspelled names
* Almost fixed duplication...
* Fix remaining completion tests
* Refactor to support multiple origins for same symbol
* Make import fixes make slightly more sense
* Add cache back in
* Set insertText based on import kind
* Update API baselines
* Add semicolons, snippet support, and sourceDisplay
* Add some tests
* Update baselines
* Fix pattern ambient modules appearing in auto imports
* Fix tests
* Remove commented code
* Switch to valueDeclaration for getting module source file
* Small optimizations
* Cache module specifiers / importableness and export map separately
* Fix and test cache invalidation logic
* Update API baselines
* Add separate user preference for snippet-formatted completions
* Require first character to match when resolving module specifiers
* Fix AutoImportProvider export map cache invalidation
* Really fix auto import provider export map invalidation
* Update test added in master
* Use logical or assignment
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
* Simply conditional by reversing
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
* When file is deleted need to marked correctly in the project as removed file
* Simplify hasAddedOrRemovedSymlinks with cherry-picked fix
* Ensure replacement range is on one line
* Update baselines
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
* Added support for private identifier methods.
* Added tests for private methods.
* Added check to only not allow private name method signatures in anything except classes.
Changes objects literal checking to not bail on first private name found in object literal.
* Added private accessors tests
* Transform private methods
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Rename shouldTransformPrivateFields
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Accept baseline
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Use a single WeakSet for brand-check
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Accept baseline
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Add a test for using private methods in static field initializers
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Add breaking checker test
Private methods inside class expressions should not error.
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Add to instances once per-instance
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Accept baseline
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* fix: evaluate receiver and rhs expressions before throwing on readonly assignment
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Add a test for evaluating rhs before readonly assignment
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Transpile private accessors
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Accept baseline
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* fix: handle readonly/writeonly accessors
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* accept baseline
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* add a test for private setter without a getter
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* fix: getAllUnscopedEmitHelpers
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* fix: better handling of duplicate names
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Fixed wrong error message for private methods in class expressions.
* change error message
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* add a test for async private methods with a higher target
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* fix: setter assignment returns rhs value
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* add a test for setter assignment return value
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* fix: handle duplicate accessors
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* add tests for duplicate accessors
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* docs: add missing parameter docs
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Fixed failing test.
* baseline-accept: ordering changes
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* fix: attach weakSetName to property declaration
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* add a test for nested private methods
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* add a test with any
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Added support for static private fields accessors and methods.
* Added error message for private identifiers used with static decorators. There is no spec to go with this behavior as of yet.
* Fixed emit static bug that used private names outside of classes for initialization in esnext. Fixed issue where nested privates produce incorrect brand check.
* Added tests for private static fields methods and accessors.
* Fixed error messages and tests after merge.
* Accept new baseline.
* Improved duplicate identifier checks for static private class elements.
* Added error when using initializers with private static fields when useDefineForClassFields is not specified and target is esnext.
* Fixed code review issues.
* Removed semantically wrong emit on `useDefineForClassFields:true` with `target:esnext`
* Changed emit for uninitialized private static fields.
* Added runtime error in helper if a static private field is accessed before it was declared.
* Fixed code review comments for private identifier static class elements.
* add debug.assertNever for unknown node type (#53)
* Fixed code review issues.
* Fixed code review issues for private class elements.
* Fixes class shadowing when checking access to a private static class element.
* fix private methods/accessors in class expr inside a loop
* collapse switch case
* fix class name
* simplify getPrivateMethodsAndAccessors
* remove findPreviousAccessorInfo
* lazily create weakSetName identifier
* do not allocate a node if not needed in visitMehodDeclaration (#55)
* Removed all the emit helpers for private identifier methods accessors and modified the existing helpers for get and set fields to do the same job.
* Simplified emit for private identifier class elements.
* do not clone the receiver (#57)
* leave bad code in for #constructor and duplicate private names (#58)
* Added check for WeakSet collision.
* Added error for using a set only accessor.
* update keyof tests and ?? (#62)
* replace ?? with ||
* update keyof tests
* fix emit helpers comments
* produce an error if private field helpers are not up to date
* add tests
* fix setter-only compound assignment
* fix tests
* fix duplicated trailing comments (#64)
* clear receiver pos and setTextRange on helper calls
Co-authored-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
* Revert "Revert "Editor support for link tag (#41877)" (#43302)"
This reverts commit 451d4354b9.
* Fix parsing @link at end of comment
* Parse comments as string when no @link occurs
* fix lint
* Narrow type variables with union constraints when merited by contextual type
* Narrow generics with union type constraints as indicated by contextual type
* Accept new baselines
* Add tests
* Fix circularity for JSX elements
* Remove unnecessary isConstraintPosition information from flow cache key
* Update comment
* Add additional tests
* Rename to getNarrowableTypeForReference, remove getConstraintForLocation
* Add comment
* Fix removal of undefined in destructurings with initializers
* Use getContextFreeTypeOfExpression in discriminateContextualTypeByObjectMembers
* In obj[x], use constraint of obj's type only when x's type is non-generic
* Add comment
* Initial scribbles
* Compiles but provides spans instead of location pairs
Probably need to fork the services/server types and provide a conversion
with Session.toFileSpan. Not sure where to put the conversion.
* Switch to DocumentSpan
In theory this is already better supported, but not sure practise bears
that out.
* Builds w/protocol types + conversions
* cleanup:better names and scrub TODOs
* fix test harness too
* Misc
1. Simplify protocol after talking to @mjbvz.
2. Add more tests.
3. Initial notes about where to add parsing.
* Parse and store links in the compiler
The text of the link is still stored in the comment text, but that's now
kept in an object instead of just a string. Each link has the parse for
the entity reference, if there is one.
Needs lots more tests -- this just makes all the existing jsdoc tests
pass.
* more tests and some fixes
* Fix other failing tests
* fix bad merge
* polish parser
* improve names and array types
* slight tweaks
* remove some done TODOs
* more tests + resulting fixes
* add+fix cross-module tests
* Support `@see {@link`
Plus find-all-refs support equivalent to @see's.
* add server test
* Make comments actually part of the AST
* Add span for link.name in language service/protocol
* Make checker optional in getJSDocTags
Also change to JSDocCommentText from JSDocCommentComment
* Use getTokenValue instead of getTokenText
Measure twice, slice once
* Add missing support for top-level links
The language service and protocol were missing support for top-level
links. This commit adds that plumbing.
* add string back to comment type in node constructors
* Full parse of link tags and jsdoc comment text
- Doesn't pass fourslash yet, I'm going to switch to baselines for
failures there.
- Still needs some work on the protocol to convert file+offset to
file+line+offset.
* fix lint
* Fix missing newlines in inferFromUsage codefix
* Parse jsdoc comments as text node/link array
And switch to line+character offsets in the protocol
* Fix fourslash tests
Mostly ones that can't be baselined, but I switched a couple more over
to baselines
* Improve types and documentation
* Test+fix @link emit, scrub other TODOs
* update API baselines
* test that goto-def works with @link
* Split link displaypart into 3
One for link prefix and suffix, one for link name, and one for link
text.
* update baselines
* Provide JSDocTagInfo.text: string to full clients by default
Instead of upgrading them to displayparts.
* Real server tests
* Disambiguate {@link} and @param x {type}
They are ambiguous; previously the parser preferred the type
interpretation, but will now look ahead and parse links instead when the
prefix is `{@link`.
* Add explanatory comment in test
* fix location in richResponse in protocol
* update API baseline
* Address PR comments
1. Add a cross-file goto-def test.
2. Switch from per-message args to UserPreference.
* use arraysEqual from core
* Finally add that missing relationship allowing a type to be assignable to both branches of a conditional
* Explicitly write out Ternary.Maybe
* Add slightly modified example from #25413
* fix sick sentence
* Loosen check to skip false branch constraint check to consider `infer` parameters as always satisfied in the extends clause
* Simplify things a bit, only instantiate once
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
* Fix property name bindings for class expr in loops
* Fix block-scope capturing with prop initializers
Co-authored-by: Joey Watts <joey.watts.96@gmail.com>
This was caused by the fact that getTypeWithFacts(resultType, TypeFacts.NEUndefinedOrNull) will return never both if resultType was already never and if resultType does not contain undefined or null. In the latter case returning the declaring type is correct, in the former case this causes something narrowed to never to still be typed as the original declared type.