11333 Commits

Author SHA1 Message Date
Anders Hejlsberg
de4a166905 Add tests 2022-03-01 14:55:42 -08:00
Nathan Shively-Sanders
5150682a58
Only suggest @param codefixes in TS (#47959)
* Only issue @param suggestions with codefixes in TS

Previously, there were 2 JS errors that were issued as suggestions in TS
files. But there was no codefix for these errors, and the errors were
incorrect in TS.

This PR only issues the JS-specific errors on JS files.

* Minimise test
2022-02-18 15:58:09 -08:00
Oleksandr T
b0b8cdafc9
feat(44956): remove hyphen separator (#47777) 2022-02-18 13:41:36 -08:00
Anders Hejlsberg
db226a80e8
Remove unnecessary check in getNarrowableTypeForReference (#47953)
* Remove unnecessary check in getNarrowableTypeForReference

* Add regression test
2022-02-18 11:03:48 -08:00
islandryu
b8b1201e44
fix(47024):fix type of DateTimeFormat and NumberFormat (#47117)
* fix type of DateTimeFormat and NumberFormat

* add NumberFormat to esnext.intl.d.ts

* Update src/lib/esnext.intl.d.ts

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

* better unification of previous changes

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-02-17 15:37:43 -08:00
Oleksandr T
51d34466e7
feat(47281): use unknown type instead of any (#47308) 2022-02-17 13:54:02 -08:00
DetachHead
092018bd7e
fix issue where duplicate default exports aren't detected (#46871)
* fix issue where duplicate default exports aren't detected when there's an interface

* accept baseline change

* add `exportDefaultInterfaceClassAndValue` test

* add more tests for multiple default exports

* add two interfaces test

Co-authored-by: DetachHead <detachhead@users.noreply.github.com>
2022-02-17 13:17:31 -08:00
Jonas Hübotter
fb1066e5d9
Uncalled function checks only works with single conditional (#42835)
* Uncalled function checks only works with single conditional

* fix type errors in compiler

* remove uncalled function checks with negations

* review

* fix test

* Cleanup after merge, accept baselines

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-02-17 11:37:55 -08:00
Anders Hejlsberg
53809d8ed1
Remove unnecessary check for misaligned complex rest parameters (#47934)
* Remove unnecessary check for misaligned complex rest parameters

* Add tests
2022-02-17 11:35:52 -08:00
Oleksandr T
1c06ef38b8
fix(47391): omit | token from jsdoc linkTag text (#47575) 2022-02-17 11:35:09 -08:00
Oleksandr T
5b947e6526
feat(47619): add support for extracting jsx string literal attribute to a constant (#47624) 2022-02-17 11:30:52 -08:00
webstrand
66dba1331b
Fix #38482 making ThisParameterType<T> more general (#47162)
`ThisParameterType<(...args: X) => void>` expands to
`(...args: X) => void extends (this: infer U, ...args: any[]) => any`.
When `X` is an unresolved type parameter it is not possible to determine
that `any[]` is assignable to `X`. However `never` is always assignable
to `X`, so we use that instead.
2022-02-17 11:28:22 -08:00
Oleksandr T
03a4df7a57
fix(47820): forbid extraction jsdoc (#47830) 2022-02-16 16:38:11 -08:00
Anders Hejlsberg
5afbfbcbd0
Instantiation expressions (#47607)
* Permit type arguments in references to generic functions

* Accept new baselines

* Delete pointless fourslash test

* Fix lint issue

* Finalize implementation

* Add tests

* Accept new baselines

* Properly handle instantiation of instantiation expression types

* Accept new API baselines

* Fix lint error

* Add more tests

* Properly handle unions/intersections of generic types

* Add more tests

* More permissive parsing of type arguments in member expressions

* Update tests

* Accept new baselines
2022-02-16 13:27:16 -08:00
Oleksandr T
b9a06e515f
fix(47261): allow linkcode/linkplain tags in see tag (#47403) 2022-02-15 17:20:51 -08:00
Oleksandr T
a0bab5de5c
fix(47256): show deprecated on index signatures (#47400) 2022-02-15 17:13:04 -08:00
Oleksandr T
39fe0318e0
feat(47223): show completion in jsdoc template tag (#47317) 2022-02-15 16:59:37 -08:00
Oleksandr T
063eaa70e6
feat(47595): allow using private fields in type queries (#47696) 2022-02-15 15:48:10 -08:00
Zzzen
81d1457738
mark length of readonly tuple as readonly (#47717) 2022-02-15 15:02:36 -08:00
Jihn Dai
1e60c8702c
Fix inference for generic-typed constructor parameter when no explicit constructor is present (#47750)
* assume signature is from constructor if declaration is undefined

* add tests and baselines
2022-02-15 14:21:44 -08:00
Wesley Wigham
67172e41c2
Triple-slash reference type directives can override the import mode used for their resolution (#47732)
* Triple-slash reference type directives can override the import mode used for their resolution

They now use the file's default mode by default, rather than always using commonjs. The new arguments to the
reference directive look like:

```ts
///<reference types="pkg" resolution-mode="require" />
```

or

```ts
///<reference types="pkg" resolution-mode="import" />
```

* Omit redundant import modes in emitter

* Add test for #47806

* Add server test for triple-slash reference mode overrides

* Move FileReference mode into helper

* Update tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride3.ts

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-02-15 13:53:11 -08:00
Oleksandr T
1b1530ae52
fix(47713): allow JSDoc tags on CaseClause nodes (#47741) 2022-02-15 13:27:54 -08:00
Gabriela Araujo Britto
67f47bf420
Fix incorrect rest element type inside contextually typed parameter (#47909)
* wip: possible fixes

* pass parameter type to assignBindingElementTypes

* undo unnecessary changes

* update baselines
2022-02-15 13:27:23 -08:00
Felipe Armoni
d13af64bde
Fix 47746 - Missing properties quickfix does not handle generic parameters (#47790)
* Added test

* Added extra test case
2022-02-15 13:09:01 -08:00
Wesley Wigham
e32281cc02
Allow extensionless mains for cjs mode packages even from an esm import (#47893) 2022-02-14 14:13:21 -08:00
Anders Hejlsberg
78ef3e70c9
Ensure empty array literal is assignable to never[] (#47816)
* Ensure empty array literal is assignable to never[]

* Add tests

* Add comment
2022-02-12 16:39:21 +01:00
Wesley Wigham
1bdb0d90bf
ESM mode nonrelative imports should assume index.js entrypoints even if no package main is present (#47854) 2022-02-11 15:44:11 -08:00
Wesley Wigham
e204acfa26
Ensure subtype relation ordering for readonly properties (#47069)
* Ensure subtype relation ordering for readonly properties

* Probably fix post-LKG assignability error
2022-02-11 14:59:01 -08:00
Wesley Wigham
033f9e0081
Consider a symbol visible for declaration emit when it is the target of an ambient module's export= (#47835)
* Consider a symbol visible for declaration emit when it is the target of an ambient module's export=

* Just use resolveExternalModuleSymbol
2022-02-11 14:58:31 -08:00
Andrew Branch
7f022c58fb
Correctly resolve imports ending with "." and ".." (#47850) 2022-02-11 11:14:07 -08:00
Oleksandr T
73506f3512
fix(46803): remove unused react imports with enabled react-jsxdev, react-jsx (#47247) 2022-02-11 11:13:26 -08:00
Wesley Wigham
4c80036b7d
Enable path completions for node12/nodenext (#47836)
* Enable path completions for node12/nodenext

* Explicitly pull path completions from export maps when available

* Explicitly handle pattern exports by stopping up to the star
2022-02-11 10:54:04 -08:00
Andrew Branch
0655f32e05
Add missing isolatedModules error for export import (#47838)
* Add missing isolatedModules error for `export import`

* Update existing baseline
2022-02-10 16:13:04 -08:00
Andrew Branch
954d0442eb
Avoid auto-importing from barrel re-exporting index files that are likely to make an import cycle (#47516)
* Avoid auto-importing from barrel re-exporting index files that are likely to make an import cycle

* Finish fixing merge conflict
2022-02-10 15:05:08 -08:00
Oleksandr T
b456702755
feat(11378): check param names in JSDoc (#47257) 2022-02-10 10:02:07 -08:00
Oleksandr T
954ce5b278
fix(46611): allow to use jsdoc type on class methods (#46688) 2022-02-10 09:17:30 -08:00
islandryu
95c22d1750
fix(47076):Fix error term of declaration in modules (#47087)
* Fix error term of declaration in modules

* fix test

* change error code of "An import declaration can only be used at the top level of a module."

* Separate js and ts files for export errors in module.

* Change non-top-level error in namespace

* format

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-02-09 13:19:30 -08:00
Gabriela Araujo Britto
2d0a00d457
Fix destructuring and narrowing interaction (#47337)
* WIP: pass in checkmode to getNarrowableTypeForReference

* add tests

* another pass through new check mode argument

* rename new check mode

* only use rest flag for rest elements in objects

* add and update tests

* change check mode flag name

* restore package-lock.json

* fix comments

* get rid of fourslash tests

* fix caching in checkExpressionCached when checkMode is not normal

* Don't distinguish between object and array rest elements

* get rid of undefined check mode

* don't make includeOptionality into checkmode flag
2022-02-09 12:25:07 -08:00
Nathan Shively-Sanders
d5c3015516
Constructor function methods:Add two missing tag lookups (#47742)
1. During name resolution, `@param` and `@return` tags should walk up
through the jsdoc comment and then jump to the host function. Previously they
did not, which would cause them to not resolve type parameters bound in
the scope of a host that was not a sibling of the comment. The example
from #46618 is a prototype method:

```js
/**
 * @template {T}
 * @param {T} t
 */
C.prototype.m = function (t) {
}
```

2. During name resolution, prototype methods are supposed to resolve
types both from the host function's location and from the containing
class' location. The containing class lookup happens in a separate call
to `resolveName`. Previously, the code that finds the containing class
only worked for the above style of comment, which is on the outer
ExpressionStatement, but not for the below style, which is on the
function expression itself:

```js
C.prototype.m =
  /**
   * @template {T}
   * @param {T} t
   */
  function (t) {
}
```
2022-02-09 11:22:33 -08:00
Andrew Branch
2cf5afd49e
Avoid pulling on setter type when only getter type is needed to break circularity (#47818) 2022-02-09 10:56:29 -08:00
Oleksandr T
c06849ad16
fix(47787): show QF to delete parameter in getter (#47797) 2022-02-08 13:39:54 -08:00
Andrew Branch
c5b1011e94
Compute writeType from set accessors for union and intersection properties (#47674)
* Compute write type from set accessors for union and intersection properties

* Add test for deferred writeType

* Always check for writeType of symbol
2022-02-08 12:57:34 -08:00
Oleksandr T
17b97ccc43
fix(47788): forbid convertToMappedObjectType QF in invalid index signatures (#47798) 2022-02-08 11:36:45 -08:00
Andrew Branch
d8ac54bfb1
Fix substitution types of indexed access types of substitution types (#47791)
* Fix substitution types of indexed access types of substitution types

* Add tests

* Fix accidental unindentation
2022-02-07 15:53:13 -08:00
Oleksandr T
867470ca26
fix(47783): show globals completion in case keyword outside of switch statement (#47786) 2022-02-07 14:08:35 -08:00
Oleksandr T
afeacf41bd
fix(47782): forbid super() extraction outside this container (#47784) 2022-02-07 13:26:39 -08:00
Andrew Branch
9c3b41d3cc
Refactor named imports to default instead of namespace when esModuleInterop is on and module is an export= (#47744) 2022-02-04 17:11:25 -08:00
Oleksandr T
8ddead50eb
fix(32941): include Template tag constraint to QuickInfo response (#47567) 2022-02-04 16:12:23 -08:00
Ron Buckton
3328feb799
Use 'static {}' for static fields when available and useDefineForClassFields is false (#47707) 2022-02-04 12:34:29 -08:00
Oleksandr T
ceee975052
fix(45917): show completions in string literal followed by a comma (#46970) 2022-02-04 12:15:02 -08:00