Commit Graph

10406 Commits

Author SHA1 Message Date
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
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
Tim van der Lippe
8d7afc2b21 Add DockerFile for ChromeDevTools (#39624)
* Add DockerFile for ChromeDevTools

Note that I was not able to verify it fully works, as it throws an
authentication error on typescript/typescript on the Docker Hub.

This is part of #39568

CC @weswigham

* Fix run command

* Update run command
2020-09-05 02:35:38 -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
Andrew Branch
f6f2d36ee3 Add optionalReplacementSpan to completions response (#40347)
* Add optionalReplacementRange to completions response

* Get the name right

* Fix unit tests

* Fix comment typo

* Fix comment typo

* Baseline
2020-09-04 13:09:52 -07:00
Alexander T
8384018e68 fix(26141): show completions for string parenthesized types (#39697) 2020-09-04 12:15:16 -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
Alexander T
db5f519514 fix(31126): show completions in nested namespace name (#39663) 2020-09-03 13:32:03 -07:00
Alexander T
38cedc5b5f fix(39410): don't remove variables with type definition during converting named export to default (#39505) 2020-09-02 17:00:43 -07:00
Andrew Branch
838a5e6044 Fix call hierarchy item serialization and server tests (#40348) 2020-09-02 11:34:14 -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
Andrew Branch
bfb00eb164 Fix misplaced comma in auto imported specifier (#40273) 2020-08-31 10:54:53 -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
Ron Buckton
10fb9c9381 Treat trailing 'void' as optional for assignability (#40231) 2020-08-28 09:12:09 -07:00
Alexander T
fa5e9807e8 fix(40010): add outlining for comments before variables statements (#40016) 2020-08-27 16:29:05 -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
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
Wesley Wigham
76639f1585 Revamp dockerfile for office-ui-fabric to reduce noise (#40147)
* Revamp dockerfile for office-ui-fabric to reduce noise and better handle recent changes to project structure

* Revert baseline change so it can be in the normal update, use node 12 since its LTS
2020-08-20 12:01:26 -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
Andrew Branch
dbab46c363 The falsy part of any/unknown is any/unknown (#39529) 2020-08-18 11:06:44 -07:00
Alexander T
9f3af67929 fix(10019): allow renaming labels (#40064) 2020-08-18 01:04:49 -07:00
Wesley Wigham
f9cca25cd7 Fix lack of error on default export of nonexistant name (#40094)
* Modify test harness so it can report underlying issue, fix small parent pointer issue

* Fix underlying export asignment check issue and fix lints

* Ensure class/function duplicate declaration errors are reported regarless of which is encountered first

* Ensure flag conflict errors are reported regardless of which declaration is encountered first
2020-08-17 15:30:19 -07:00
Nathan Shively-Sanders
c3d41bbb73 Alias for commonjs require in JS (#39770)
* First attempt at aliases for require

* test+initial support for const x=require

* 1st round of baseline improvements

* 2nd round of baseline updates

* support property access after require

* check @type tag on require

* forbid expando missing namespaces on aliases

taken from #39558 as soon as it was created

* accept error baselines that are good, actually

* Scribbling on d.ts emit code

* use getSpecifierForModuleSymbol

* hideous hack for module.exports of aliases

* Fix module.exports.x --> export list emit

* fix isLocalImport predicate

* require only creates aliases in JS

* re-handle json imports

* update fourslash baseline

* Cleanup in the checker

1. Simplify alias resolution.
2. Simplify variable-like checking.
3. Make binding skip require calls with type tags -- they fall back to
the old require-call code and then check from there.

I haven't started on the declaration emit code since I don't know what
is going on there nearly as well.

* Function for getting module name from require call

* First round of cleanup plus a new test

Found one missing feature, not sure it's worth adding.

* more small cleanup

* more cleanup, including lint

* use trackSymbol, not serializeTypeForDeclaration

* Code review comments, plus remove unneeded code

Ad-hoc type reference resolution for `require` isn't needed anymore.

* find all refs works

* remove old ad-hoc code

* make it clear that old behaviour is not that correct

* update api baselines

* remove outdated comment

* PR feedback

1. Fix indentation
2. Add comment for exported JSON emit
3. Add test case for nested-namespace exports.

* add a fail-case test (which passes!)
2020-08-17 14:00:37 -07:00
Anders Hejlsberg
cd30534327 Recursive conditional types (#40002)
* Support recursive conditional types

* Accept new API baselines

* Accept new baselines

* Simplify recursive type tracking in type inference

* Accept new baselines

* Add tests

* Accept new baselines

* Revise recursion tracking in type inference

* Revise tests

* Accept new baselines

* Add more tests

* Accept new baselines
2020-08-15 18:22:30 -07:00
Zen
0ed523bb60 fix jsx completions after attributes (#39859)
closes #39530
2020-08-13 16:14:12 -07:00
Eli Barzilay
620e260576 Avoid the double-symbol trick for enums
Nameless jsdoc typedefs have their exportedness controlled by the
exportedness of the location they pull their name from.

Fixes #33575.
2020-08-12 18:40:57 -04:00
Nathan Shively-Sanders
d371ae770d No this-property assignments in TS (#40009)
* No this-property assignments in TS

Even when `this` is aliased, which I mistakenly allowed in #39908.

* remove errant file
2020-08-11 15:46:49 -07:00
Wenlu Wang
57e2fe0462 Improve deprecated suggestion node position (#39702)
* Improve deprecated suggestion node position

* fix typo

* Simplify code

* merge helper function
2020-08-10 17:37:11 -07:00
Wenlu Wang
a80f60c6d6 fix export * as default syntax (#39803)
* fix export * as default syntax

* update comments
2020-08-10 16:56:45 -07:00
Nathan Shively-Sanders
1ec71f0e0c Bind alias ThisProperty assignment declarations (#39908)
* Bind alias ThisProperty assignment declarations

This is a quick prototype that does the wrong thing at the wrong time
with the wrong technique.

* Preliminary checker handling for aliases

Duplicative and untested, but I think I updated all the places that need
updating.

* new is error; old one should not have been removed

* I don't even know what's happening with this test

* cleanup and testing in the checker

* binder: use lookupSymbolForNameWorker instead of mutable

This should have about the same behaviour and is much easier to
understand.

Also refactor common code a bit.

* Shorter name of lookupSymbolForName

Once upon a time there was a parent/worker function, but now it's just a
single function again. No need for the -Worker suffix.

* remove oodate comment

* fix switch-case-break lint

* Refactor and move functions

* Rename and improve type of getContextualTypeForAssignmentDeclaration
2020-08-10 16:45:55 -07:00
Nathan Shively-Sanders
3328fdb2d8 Use isUncalledFunctionReference for aliases too (#39950)
* Use isUncalledFunctionReference for aliases too

Fixes bogus deprecated notices on imports of functions with deprecated
overloads, but with some non-deprecated overloads.

Fixes microsoft/vscode#104238

* Just check all declarations, don't call isUncalledFunction
2020-08-07 10:07:55 -07:00
Jesse Trinity
91a7c359b3 Insert auto imports after header comment (#39924)
* place first import after header

* don't insert before non-header
2020-08-06 13:33:29 -07:00
Ron Buckton
fca9f451d8 Add missing 'importName' for private field helpers (#39932) 2020-08-06 13:27:19 -07:00
Andrew Branch
7f4e1b699a Find tagless JSDoc as preceding token (#39912) 2020-08-05 10:09:45 -07:00
Nathan Shively-Sanders
c9f05af2c8 Merge pull request #37891 from Neonit/jsDocIndentationPreservation
Fix indentation preservation in JSDoc (#37717)
2020-08-04 16:09:50 -07:00
Wesley Wigham
94989789df In JS declaration emit, move imports painted in nested contexts to the root private context (#39818)
* In JS declaration emit, move imports painted in nested contexts to the root private context

* Add test for nathan
2020-07-31 18:25:37 -07:00