Commit Graph

15201 Commits

Author SHA1 Message Date
Andrew Branch
083129f005 A union including non-iterable types is not iterable (#40350)
* WIP

* If method type derives solely from the global iterator or generator type, use its type arguments

* Add test for problem fixed as side effect
2020-09-11 09:31:22 -07:00
Jack Moore
4a3b195772 Add lib es2020.sharedmemory (#39541) 2020-09-11 11:34:01 -04:00
Orta Therox
cdafb7157b Replaces the default module index resolver with '/index' instead of '' when handling internal routing for dts bundles (#39277)
* Adds support for declaring the bundled name of a dts module export

Co-authored-by: Wesley Wigham <wwigham@gmail.com>

* Adds baselines

* Update the tests

* Try to reduce the scope of the bundledPackageName error

* Use the flag in more baselines

* Get it green

* More tests

* Handle more feedback

* More test cleanup

* Set the moduleResolution for the tsconfigs

Co-authored-by: Wesley Wigham <wwigham@gmail.com>
2020-09-11 08:12:07 -04:00
Nathan Shively-Sanders
b7c598ea39 Use ad-hoc code for nested destructuring in require (#40188)
* Use ad-hoc code for nested destructuring in require

Nested destructuring doesn't really map to ES imports:

```js
const { utils: { nub, intercalate } } = require('./monopackage')
```

Previously, isRequireVariableDeclaration walked up binding elements
until it reached a variable declaration. This change instead only walks
up one binding element and stops. Then it's not bound as an alias and
uses the checker-only code to produce types for the nested-imported
identifiers.

Fixes #40143

* revert binder formatting change
2020-09-10 13:07:58 -07:00
Andrew Casey
45dedd6b87 Merge pull request #40063 from amcasey/ChromeTracing
Trace key operations
2020-09-10 13:01:47 -07:00
Nathan Shively-Sanders
e350c357d2 Alias for module.exports.x = x (#40228)
* Alias for `module.exports.x = x`

This fixes #40155 in a surprisingly small amount of code.

* Treat any aliasable expression as an alias

* test internal references to exported class
2020-09-10 11:23:48 -07:00
Wesley Wigham
683979246f Fix JS declaration emit for acessors in a class/interface merge (#40456) 2020-09-10 10:39:41 -07:00
Anders Hejlsberg
6f0c91c4cb Template literal types and mapped type 'as' clauses (#40336)
* Initial implementation of string template types

* Accept new API baselines

* Accept new baselines

* Unified checking for large cross product union types

* Accept new baselines

* Ensure errors from union type resolution are reported

* Accept new baselines

* Compute constraints for string template types

* Support `as T` clause in mapped types

* Accept new API baselines

* Add missing semicolon

* Add checking of `as T` clauses

* Support casing modifiers in string template types

* Accept new baselines

* Bump keyword maximum length

* fix anders

* Revert "fix anders"

This reverts commit b3178d4618.

* Properly handle 'as T' clause with keyof for mapped type

* Fix lint error

* Single character inferences and anchored end span matching

* Fewer array copy operations in template literal type resolution

* Handle cases where 'as T' maps multiple properties onto one

* Fix lint error

* Store key type instead of type mapper in MappedSymbol

* No constraint on `in T` type when `as N` clause present

* Rename from TemplateType to TemplateLiteralType

* Accept new API baselines

* Add tests

* Accept new baselines

* Address CR feedback

* Accept new API baselines

Co-authored-by: Erich Gamma <egamma@microsoft.com>
2020-09-09 17:23:22 -10:00
Wenlu Wang
ee5f51bc0f Add see tag support (#39760)
* Add see tag parser

* add baseline

* fix symbol resolve

* add more case

* fix unittests

* improve tests and parser

* accept baseline

* Adopt package-lock.json and npm ci

* Add a workflow to update package-lock.json daily

* Git ignore package-lock.json and forcibly update in workflow

* Update bot email address

* Delete extra npm update

* Update package-lock.json

* Add compactDisplay and signDisplay to NumberFormatOptions (#40039)

* Fix typo in (Readonly)Set.keys comment (fixes #40164) (#40176)

* fix(26325): use a unique name for reserved words in 'constructor like' function name (#39684)

* fix(25770): add diagnostic message for the possible mapped type used as an index (#39973)

* fix(31046): add new diagnostic message for incompatible constructor signature (#40073)

* Update package-lock.json

* Update package-lock.json

* Add rename support

* Accpet baseline

* wip

* fix anders

* Revert "fix anders"

This reverts commit b3178d4618.

* Fix call hierarchy item serialization and server tests (#40348)

* Avoid error

* accept baseline

* Add more tests

* Add signature name resolve

Co-authored-by: Andrew Casey <andrew.casey@microsoft.com>
Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
Co-authored-by: Neil Kistner <neil.kistner@gmail.com>
Co-authored-by: cherryblossom000 <31467609+cherryblossom000@users.noreply.github.com>
Co-authored-by: Alexander T <alexander.tarasyuk@outlook.com>
Co-authored-by: Erich Gamma <egamma@microsoft.com>
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
2020-09-09 10:45:09 -07:00
Alex T
6aec7f4676 feat(25770): add Quick Fix to convert LiteralType to MappedType (#40226) 2020-09-08 14:18:53 -07:00
Alex T
15084465b7 fix(40222): fix crash on using destructuring in a catch clause (#40240) 2020-09-08 11:49:45 -07:00
Orta Therox
fa89ce6158 Remove assignability cases in getNarrowedType + an isArray improvement for readonly arrays (#39258)
* Explore using a different isArray declaration

* Add tests and the new isArray definition

* Baseline updates

* Upda the isArray type
2020-09-08 14:43:48 -04:00
Wesley Wigham
7838b0172a Add errors when providing type arguments for intrinsic JSX tags (#40293) 2020-09-08 10:29:15 -07:00
Anders Hejlsberg
cea1cfb82e Consistently error when rest element isn't last in tuple type (#40254)
* Consistently error when rest element isn't last in tuple type

* Add regression test

* Accept new baselines

* Stricter circular recursion check in type inference

* Revert "Stricter circular recursion check in type inference"

This reverts commit 80e6df6230.

* Revert "Accept new baselines"

This reverts commit 355706dadc.

* Accept new baselines
2020-09-08 07:14:16 -10:00
cherryblossom000
2ef393ba7d Add full stops in diagnostic messages (#40165)
* Add full stops in diagnostic messages (fixes #37753)

* Accept baselines

* Fix whitespace
2020-09-08 08:47:52 -07:00
Wesley Wigham
e5fd0dd1e3 Allow private symbols to be control flow narrowed (#39978)
* Allow private symbols to be control flow narrowed

* Add test with narrowing of inferred control flow type for completeness

* Reformat long line
2020-09-05 02:48:45 -07:00
Wesley Wigham
155610e114 Better support class instances assigned to the module object for JS declarations (#40037)
* Better support class instances assigned to the module object for JS declarations

* Extract constant
2020-09-05 02:23:12 -07:00
Alexander T
09d68efae1 fix(28516): forbid using async modifier with the abstract modifier (#39963) 2020-09-04 14:59:53 -07:00
Eric Anderson
79f919e8f5 Fixes stack overflow when exporting a lot in commonjs (#38994)
* Fixes stack overflow when exporting a lot in commonjs

Fixes #38691

* Add missing test files
2020-09-04 09:01:59 -07:00
Andrew Branch
8ffb7f083d Reprioritize cross-project module specifier suggestions for auto-import (#40253)
* Add test

* Suggest `paths` module specifiers even when a node_modules path was available

* Fix some tests

* Fix remaining tests

* Add comments
2020-09-03 14:00:06 -07:00
Ron Buckton
d89635381a Add support for vscode-js-debug's customDescriptionGenerators (#40308) 2020-09-02 20:05:50 -07:00
Andrew Casey
ef1481c8a4 Correct bottoming-out tracing for recursiveTypeRelatedTo 2020-09-01 16:46:07 -07:00
Nathan Shively-Sanders
b0011feee1 Checkjs implies allowjs (#40275)
* Passing --checkJs always sets --allowJS

Even if you have `"allowJs": false`. This is not a useful combination.

Changing this makes the compiler more friendly and easier to describe.

* only set allowjs if not explicitly set

* remove stray newline

* restore bad config error

* use an accessor function instead
2020-09-01 10:16:08 -07:00
Nathan Shively-Sanders
d572dcb272 Fix crash intersecting dynamic import w/esModuleInterop (#40249)
* Fix crash intersecting dynamic import w/esModuleInterop

The dynamic import shim creates a symbol without some properties that
the intersection-creating code assumes are present as of #38673.

This PR adds the smallest possible set of properties to avoid the crash.
I'm not sure what others would be good to add.

* Use symbol's declarations instead

* Fix getResolvedMembersOrExportsOfSymbol instead

* comment from code review
2020-09-01 09:10:36 -07:00
Nathan Shively-Sanders
378083fcec Nested assignment to a require alias isn't a declaration (#40186)
This is not something we can type correctly, and doesn't work in
Typescript either. Better to ignore it in JS.
2020-09-01 08:20:56 -07:00
Andrew Branch
7a0f603b11 Fix extract symbol crash on unterminated literals; don’t offer to extract export = ... (#40272)
* Don’t offer to extract export assignment

* Terminate unterminated literals when extracting them

* Add test with regular expression ending in backslash

* Add test for string literal ending in backslash

* Remove unused parameter default
2020-08-31 14:17:09 -07:00
Alexander T
01362a3ac1 feat(part of 40169): add spelling suggestion/quick fix for module/namespace exported members (#40211) 2020-08-29 01:01:06 -07:00
Andrew Casey
36489ff5c6 Add instantaneous events when depth limits are hit 2020-08-28 15:51:52 -07:00
Ron Buckton
10fb9c9381 Treat trailing 'void' as optional for assignability (#40231) 2020-08-28 09:12:09 -07:00
Ryan Cavanaugh
b969b58399 Use a correct Object.entries polyfill (#40268)
* Use a correct Object.entries polyfill

Fixes #40243

* Update src/compiler/core.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* Added parentheses, DANIEL.

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2020-08-28 09:09:55 -07:00
Josh Goldberg
0298033db7 Specified error diagnostic for invalid variable names (#40105)
* Specified error diagnostic for invalid variable names

* Use callback directly, and isKeyword
2020-08-27 10:58:12 -07:00
Eli Barzilay
746bdb7946 Fix getContextualTypeForBindingElement for arrays
When handling an array type, the lookup should use the position index
instead of the identifier name.

Also uncomment the tests in the `staticFieldWithInterfaceContext.ts`
test which failed because of this bug.

Fixes #40158.
2020-08-26 16:28:50 -04:00
Kyℓe Hensel
c5446d1a47 don't emit "unused @ts-expect-error" in unchecked js files (#40046)
* don't emit unused ts-expect-error in unchecked js files

* simplify code
2020-08-25 11:04:23 -07:00
Nathan Shively-Sanders
4aadd5af41 Fix commonjs require of ES export (#40221)
The commonjs-specific code for resolving access expressions on `require`
assumes a fake commonjs export. For real exports, it needs to call
resolveSymbol since it's outside the normal alias-resolving
infrastructure.
2020-08-24 12:37:25 -07:00
Alexander T
2dd7a4bf93 fix(31046): add new diagnostic message for incompatible constructor signature (#40073) 2020-08-22 13:26:13 -07:00
Andrew Casey
7b40895b29 Record the recursion ID of each type, if available 2020-08-21 17:39:03 -07:00
Andrew Casey
00804d8aa6 Trace structuredTypeRelatedTo, rather than recursiveTypeRelatedTo 2020-08-21 17:07:13 -07:00
Andrew Casey
a0479da1e5 Revert System changes and consume fs directly 2020-08-21 17:07:13 -07:00
Andrew Casey
5d60972ef4 Trace key operations
Produce output in Chrome's event tracing format so that it can be viewed
in Chrome/Edge.
2020-08-21 17:07:12 -07:00
Alexander T
9569198df6 fix(25770): add diagnostic message for the possible mapped type used as an index (#39973) 2020-08-21 10:42:48 -07:00
Alexander T
6ec3629ef4 fix(26325): use a unique name for reserved words in 'constructor like' function name (#39684) 2020-08-21 09:47:37 -07:00
Eli Barzilay
f9e360d44b Add missing contextual type to static PropertyDeclarations
Makes it possible to type class static fields.

Fixes #33897.
2020-08-20 19:12:55 -04:00
Ron Buckton
598e9b2e88 Allow trailing params of 'undefined', 'unknown', and 'any' to be optional in non-strictNullChecks JS (#40057) 2020-08-20 13:38:14 -07:00
Joost Koehoorn
2f2b679436 Optimize external source maps without full cache (#40130) 2020-08-19 16:05:32 -07:00
Nathan Shively-Sanders
55ca5e91b9 Fixes crash on chained property access on require (#40135)
From the user tests:

```js
const x = require('y').z.ka
```

would cause the crash because I forgot to call
getLeftMmostPropertyAccessExpression in one place.

Note that this doesn't fix the alias, it just stops the crash.
2020-08-19 12:59:22 -07:00
Wesley Wigham
44d2350e5f Fix tuple name homogeneity check (#40118) 2020-08-19 12:08:17 -07:00
Daniel Rosenwasser
31f4957494 Revert "Optimize source mapping into external source map sources (#40055)" (#40126)
This reverts commit 1e84ffc703.
2020-08-19 11:46:52 -07:00
Joost Koehoorn
1e84ffc703 Optimize source mapping into external source map sources (#40055) 2020-08-18 18:09:05 -07:00
Andrew Casey
5ff1b75aff Merge pull request #40043 from gluxon/uvException-hotspot
Set stackTraceLimit to 0 in fileSystemEntryExists
2020-08-18 13:54:58 -07:00
Nathan Shively-Sanders
6fea7ff536 Add unit tests for VersionRange (#40114)
* Add unit tests for VersionRange

Make it easier to understand the intended semantics next time I have to
read this code.

* I miss prettier
2020-08-18 13:06:17 -07:00