Commit graph

29744 commits

Author SHA1 Message Date
Andrew Branch e1bce187a8
Type-only auto imports (#36412)
* WIP

* Promote existing type-only imports to regular if needed

* Add completions test adding to type-only import

* Update tests, revert whole-import-clause replacement codefix strategy to preserve import specifier formatting

* Revert unnecessary changes

* Delete unused function

* }
2020-01-27 12:53:32 -08:00
Nathan Shively-Sanders 757e67041e
Fix getExpandoSymbol for already-expando symbols (#36457)
* Fix getExpandoSymbol for already-expando symbols

getExpandoSymbol is intended to get the symbol of the expando in a
declaration like

```js
var C = class {
}
```

However, when this occurs in a `module.exports` assignment, alias
resolution already jumps to the exported symbol -- in this case the
expando symbol:

``js
// @filename: first.js
module.exports = class {
}
// @filename: other.js
/* @type {import("./first")} */
var C
```

`getExpandoSymbol` is then called on `class { }` instead of
`module.exports = class { }`.

Previously, `getExpandoSymbol` would incorrectly treat `class { }` the
same as the export assignment and get the expando ... from the expando
itself. This resulted in merging the expando with itself, which causes
bogus errors and could cause other problems.

Now `getExpandoSymbol` checks that the expando "initializer" is
different from the declaration.

* Better check for getExpandoSymbol of expando

Check the declaration directly instead of the initialiser.
2020-01-27 12:32:56 -08:00
Alexander T c239626f23 fix(36140): handle quotesPreference option in interface implementation (#36398) 2020-01-27 12:25:31 -08:00
Andrew Branch 20e8eba143
Issue better error for exporting primitive type (#36424)
* Issue better error for exporting primitive type

* Delete nonsense
2020-01-27 08:11:21 -08:00
Alexander T 30545006df fix(36068): Incorrect quick fix for undeclared private field i… (#36373) 2020-01-24 18:28:42 -08:00
Wesley Wigham 18cd79e179
Allow infer type variables to have constraints inferred (#32093)
* Allow `infer` type variables to have constraints infered and allow the breakdown of substitutes in simplifiable source inferences

* Still skip conditional inference when `extends infer Q` so such a pattern still acts as a constraint size breaker
2020-01-24 16:59:20 -08:00
Wesley Wigham 08e6bc20bb
Trampolines for large binary expressions (#36248)
* WIP

* Test no longer crashes, but emit trampoline is incomplete and skips pipeline phases

* Fix lints, use non-generator trampoline in emit (still skips pipeline)

* Final version with emitBinaryExprssion work stack that is only used if possible

* Fix lints

* retarget to es2015 for testing

* Use bespoke state machine trampolines in binder and checker

* Remove now extraneous code in parser

* Adjust fixupParentReferences to use a depth first preorder traversal rather than breadth first

* Reintroduce incremental fast bail in fixupParentReferences

* Revert target to es5

* PR feedback

* Small edit for devops rebuild with updated definition

* Fix comment nits, add internally extraneous check back into transformer
2020-01-24 16:29:55 -08:00
Ben Lichtman e479a9f679 Respond to CR 2020-01-24 16:23:54 -08:00
Wesley Wigham f3cc6f6d84
Remove distinction between CI lint and local lint (#36430) 2020-01-24 16:23:14 -08:00
Sheetal Nandi 096e1b12e4
Handle error reporting of files when new file is created after its opened in editor (#36271)
* If script info is not attached to the project on which wild card is invoked, update it.

* Instead of getting default project before starting error list timer, get it at that time if no project is specified
Fixes #35794

* Fix the open File watch triggered setting
2020-01-24 16:07:48 -08:00
Ben Lichtman 8c18c7683a Add tests 2020-01-24 16:02:14 -08:00
Klaus Meinhardt 8e0b091795 es2018: visit other binding elements when transforming object destructuring with rest (#35872)
* es2018: visit other binding elements when transforming object destructuring with rest

fixes: #35771

* more tests
2020-01-24 15:50:29 -08:00
Wesley Wigham 7c05e1a78c
Add --force option to npm install commands in dockerfiles (#36431) 2020-01-24 15:29:27 -08:00
Ben Lichtman f047111c64 Track changes to redirect info 2020-01-24 15:15:05 -08:00
Wesley Wigham 9ef9bb04f1
Fix crash on erroneous enum member merged with exported type alias (#36429) 2020-01-24 15:00:15 -08:00
Nathan Shively-Sanders 368db997ed
ESNext+[[Define]]: reference to param props illegal (#36425)
* ESNext+[[Define]]: reference to param props illegal

When target: "esnext" and useDefineForClassFields: true, property
declaration initialisers should not be able to reference parameter
properties; class fields are initialised before the constructor runs,
but parameter properties are not:

```ts
class C {
  foo = this.bar
  constructor(public bar: string) { }
}
```

emits code that looks like this:

```js
class C {
  bar
  foo = this.bar
  constructor(bar) {
    this.bar = bar
  }
}
new C('x').foo.length // crashes; foo is undefined
```

This PR adds an error on foo's declaration with ESNext+[[Define]].

* improve test
2020-01-24 14:53:28 -08:00
Nathan Shively-Sanders 43fc19c958
Emit statements before super (#36417)
* Emit statements before super

When statements come before super, Typescript's emit is incorrect,
whether there is an error or not. This change preserves statements that
come before super whether there is an error or not.

Here is the case with no errors:

```ts
class Test extends Array {
  p: number
  constructor() {
    console.log("p is initialised in the constructor below super()")
    super()
    this.p = 1
  }
}
```

Notice that `p` is manually initialised in the constructor after
`super()` instead of at the property declaration.

* Update baselines

Parameter properties in the error case now move below the super call.
This is an improvement because it means the code is more likely to execute
correctly.

* remove outdated comments
2020-01-24 14:52:48 -08:00
Ron Buckton 98110904da
Adds extension recommendation for rbuckton.tsserver-live-reload (#36426) 2020-01-24 14:10:27 -08:00
Wesley Wigham 6b64c883f1
Fix crash on missing parent pointer in binder when transpiling export as ns (#36387) 2020-01-24 13:36:05 -08:00
Andrew Branch 751eb44e21
Add more detailed log for bad codefix request (#36420) 2020-01-24 12:55:08 -08:00
TypeScript Bot 77d790b62a Update user baselines (#36411) 2020-01-24 12:35:54 -08:00
Sheetal Nandi 29895e8906
Handle header comments better by comparing its end line with first node line (#36413)
Fixes #31508
2020-01-24 11:20:41 -08:00
Andrii Dieiev 420b478c65 Add prefix/suffix only to binding element name (#33538) 2020-01-24 10:46:41 -08:00
Wesley Wigham 9e712dd097
Consider SymbolFlags.Method as function-esque during js declaration emit (#36274) 2020-01-24 10:29:23 -08:00
ExE Boss 6f0c6417e8 fix(lib/es2019): Symbol.description may be undefined (#36263)
* fix(lib/es2019): `Symbol.description` may be `undefined`

* Update user baselines (EB-Forks#1)

Co-authored-by: TypeScript Bot <ts_bot@rcavanaugh.com>
2020-01-24 10:06:04 -08:00
TypeScript Bot 3b919e2ab1 Update user baselines (#36382) 2020-01-23 14:12:40 -08:00
Ben Lichtman 703685318c Merge branch 'master' into redirectInfo 2020-01-23 14:12:01 -08:00
Ben Lichtman 09528dd6d6 Add tests 2020-01-23 14:10:37 -08:00
Klaus Meinhardt 49eb0d7a2b Disallow 'declare' modifier on private named properties (#36381)
Fixes: #36345
2020-01-23 13:18:10 -08:00
Sheetal Nandi 677e45ccb8
Dont add "use strict" prologue in json emit (#36380)
* Add test for strict with isolated modules and resolveJson
Test for #36372

* Dont add "use strict" prologue in json emit
Fixes #36372
2020-01-23 13:01:11 -08:00
Andrew Branch b05dde747c
Update type-only import semantics to allow type queries (#36092)
* Change type-only semantics to allow type queries

* Don’t error using type-only import in ambient context

* Fix default import

* Fix namespace import

* Update more baselines

* Prevent circular resolution

* Track const enum expression usage

* Update baselines

* Perf tuning 1

* Test commit for perf impact

* Weave type-only alias declaration finding into alias resolution

* Fix namespace import of type-only exported symbols

* type-only exports do not contribute to the module object type

* Update APIs

* Fix enum casing, remove type-only conversion suggestion

* Short circuit type-only checks in resolveEntityName faster

* Fix casing in API

* Remove unused parameter

* Fix error on qualified names in type queries

* Allow type-only imports in computed property names

* Fix computed property names of types and abstract members

* Remove unused util

* Commit missing baselines

* Rename “check” functions so as not to overload the word “check”
2020-01-23 12:53:36 -08:00
Ben Lichtman c9c3792747 Produce redirect info about files when requested 2020-01-23 12:32:36 -08:00
Klaus Meinhardt 0276e7f910 noErrorTruncation affects semantic diagnostics (#36306) 2020-01-23 11:10:05 -08:00
Nathan Shively-Sanders ef5573b266
Add as completions (#36359) 2020-01-23 08:29:06 -08:00
Wesley Wigham 75f88eee48
Do not short-circuit module visibility calculation when alias visibility is requested (#36339) 2020-01-22 14:49:29 -08:00
Andrew Branch eac2180e40
Be more tolerant with private identifier parsing, issue more targeted errors, and support private identifiers in forgotten 'this' codefix (#36188)
* Support private identifiers in forgotten this codefix

* Parse invalid private identifiers as identifiers and issue targeted errors

* Update codefix

* Remove accidentally deleted newline
2020-01-22 13:41:15 -08:00
Nathan Shively-Sanders 770fbcb42f
Add jest to fp-ts user test (#36360)
It was missing because I *think* they just added it.
2020-01-22 13:38:25 -08:00
Andrew Branch 1d5749ef78
Fix local and exported type alias merging (#36237)
* Fix local and exported type alias merging

* Add baselines
2020-01-22 13:16:49 -08:00
Orta 82a3eb5b5f
Add a list of PR owners for tooling to use (#36357) 2020-01-22 15:09:01 -05:00
Anders Hejlsberg da61231039
Include super.XXX(...) assertion method calls in CFA (#36293)
* Support super.XXX in assertions

* Add tests
2020-01-22 11:21:11 -08:00
Nathan Shively-Sanders c8e2f58ec5
Completions for asserts and declare (#36355)
* Add completions for `asserts`

* Add declare assertions.
2020-01-22 10:43:33 -08:00
Orta 5e59eece34
Adds support for showing default exports in the navtree (#35477)
* Adds support for showing default exports in the navtree - Fixes #34601

* Handle the feedback in #35477

* Navigation items using default export or export = will get noted if they are a const vs function
2020-01-22 08:13:04 -05:00
Alexander T 38eccbab2a feat(29624): better errors for non-exported types (#36187) 2020-01-21 13:03:22 -08:00
Klaus Meinhardt 342f4c0b54 forceConsistentCasingInFileNames affects module resolution (#36334) 2020-01-21 12:45:13 -08:00
Daniel Rosenwasser 8976ac96aa Update LKG. 2020-01-21 12:35:42 -08:00
Klaus Meinhardt 1fbe20fe75 resolveJsonModule affectsModuleResolution (#36290)
* resolveJsonModule affectsModuleResolutionFixes: #36251

* fix lint
2020-01-21 11:49:38 -08:00
Klaus Meinhardt bc1e7728df experimentalDecorators and emitDecoratorMetadata affect builder state (#36297)
* experimentalDecorators and emitDecoratorMetadata affect builder state

* better test
2020-01-21 11:28:55 -08:00
Klaus Meinhardt 2dd21a08f5 useDefineForClassFields affects emit (#36308)
* useDefineForClassFields affects emit

* fix lint
2020-01-21 11:28:04 -08:00
Yacine Hmito 4445e1147c Fix isProgramUpToDate when changing rootFileNames (#36011) 2020-01-21 11:26:17 -08:00
Orta f588c78aab
Remove the compiler diag 1360 after it got missed in #35751 (#36332) 2020-01-21 11:54:48 -05:00