29204 Commits

Author SHA1 Message Date
TypeScript Bot
c021b28597 Cherry-pick PR #34987 into release-3.7 (#35303)
Component commits:
5810765259 Emit defineProperty calls before param prop assignments
Note that I restricted this to --useDefineForClassFields is true.
Nothing changes when it's off. I think this is the correct fix for a
patch release.

However, in principal there's nothing wrong with moving parameter
property initialisation after property declaration initialisation. It
would be Extremely Bad and Wrong to rely on this working:

```ts
class C {
  p = this.q // what is q?
  constructor(public q: number) { }
}
```

But today it does, and probably somebody relies on it without knowing.

ec7959091a Put parameter property initialiser into defineProperty's value

be863550b7 Merge branch 'master' into fix-defineProperty-parameter-property-emit

8ff59b98b8 Combine ES5/ESNext into one test
2019-11-22 16:26:51 -08:00
TypeScript Bot
d5bcb6f904 Cherry-pick PR #35058 into release-3.7 (#35241)
Component commits:
8ae5a8cfce useDefineForClassFields skips emit of ambient properties
Previously:

```ts
class C {
  declare p
}
```

would incorrectly emit

```js
class C {
    constructor() {
        Object.defineProperty(this, "p", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: void 0
        });
    }
}
```

when useDefineForClassFields was turned on (for targets <ESNext).

0ec9c04896 Fix bug for ESNext as well
This moves the check earlier in the pipeline.

e1aa034a7a update baselines
2019-11-22 14:52:31 -08:00
TypeScript Bot
b9d52319ef Cherry-pick PR #35198 into release-3.7 (#35240)
Component commits:
9c0fab93b2 Fix crash with Object.defineProperty for imported alias (--allowJs)
Fixes #35196
2019-11-20 13:20:25 -08:00
TypeScript Bot
c18d72f220 Cherry-pick PR #35209 into release-3.7 (#35213)
Component commits:
74a6343925 Fix the usage of pattern matching for check of hasZeroOrOneAsteriskCharacter Fixes #35171

ffe82c637f Fix error message
2019-11-20 10:56:03 -08:00
TypeScript Bot
b37cc6e961 Cherry-pick PR #35111 into release-3.7 (#35116)
Component commits:
6945a72130 Support dynamic file names with project root path Fixes #35094

cc30b36c59 Remove unexpected change
2019-11-14 15:37:37 -08:00
Daniel Rosenwasser
adaacd1bc1 Fix build script. 2019-11-14 14:17:13 -08:00
Daniel Rosenwasser
f7629ec045 Update version number. 2019-11-14 14:11:31 -08:00
TypeScript Bot
2e3878339b Cherry-pick PR #34588 into release-3.7 (#34988)
Component commits:
99328e9072 Propagate 'undefined' instead of the optional type marker at an optional chain boundary

7aa6eee514 Merge branch 'master' into fix34579
# Conflicts:
#	src/compiler/utilities.ts

61e6765808 Update src/compiler/types.ts
Co-Authored-By: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2019-11-14 09:54:30 -08:00
Klaus Meinhardt
12e8b0813e strip QuestionToken from MethodDeclaration and PropertyDeclaration emit (#34954)
* strip QuestionToken from MethodDeclartion emit

Fixes: #34953

* test property emit
2019-11-12 13:00:37 -08:00
Nathan Shively-Sanders
dfe2f07f88 Fix import type resolution in jsdoc, mark 2 (#35057)
Fake alias resolution only applies when the import type is followed by a
qualified name. Otherwise the alias is sufficiently resolved already.
2019-11-12 12:59:51 -08:00
TypeScript Bot
93b1aa3e0b Cherry-pick PR #34513 into release-3.7 (#34800)
Component commits:
62aad54b98 Fix a crash when transforming functions in modules.
When transforming a module declaration and block, parse tree nodes
contained in the module block have their parent pointers reset due to
`shouldEmitModuleDeclaration` calling into `isInstantiatedModule`, which
needs to set parent pointers to operate.

That causes a crash when later transforming any nodes within the module,
as retrieving their source file in `getSourceFileOfNode` (via
`getOrCreateEmitNode`) fails, due to their new synthesized parent nodes
not being in a source file.

This change avoids the issue by using the parse tree node in `ts.ts` to
decide whether a module declaration should be emitted (i.e. whether the
module contains values).

This means transformers cannot add values to modules that previously did
not contain any.

Fixes #34644.
2019-11-11 08:20:31 -08:00
TypeScript Bot
4d5f30dee0 Cherry-pick PR #34906 into release-3.7 (#35006)
Component commits:
dfa4bc0d75 Use empty object for invalid package json contents instead of undefined Fixes #34726

4d035ba5f8 Behave as if package json doesnt exist in case of invalid json in package json
2019-11-08 14:07:46 -08:00
TypeScript Bot
a22ad161a3 Update user baselines (#34842) 2019-11-07 14:13:50 -08:00
TypeScript Bot
7cf6c70d90 Update user baselines (#34837) v3.7.2 2019-10-30 16:58:46 -07:00
Daniel Rosenwasser
2f876d9532 Update LKG. 2019-10-30 15:32:34 -07:00
TypeScript Bot
88d867dc39 🤖 Cherry-pick PR #34721 into release-3.7 (#34811)
* Cherry-pick PR #34721 into release-3.7

Component commits:
c8bdddf4fd Allow export declaration to reference const enums

857e7c43a2 Update baselines

6e0da2b563 Add test to verify reexported const enums are elided

* Update LKG
2019-10-30 15:28:36 -07:00
TypeScript Bot
da0c1f8755 Cherry-pick PR #34791 into release-3.7 (#34834)
Component commits:
3904be131a Add circularity checking during deferred type argument creation
2019-10-30 14:01:24 -07:00
TypeScript Bot
068ae6973d Update user baselines (#34835) 2019-10-30 13:59:34 -07:00
TypeScript Bot
60bf24d1e5 Cherry-pick PR #34786 into release-3.7 (#34833)
Component commits:
f6dbbfd80d Fix alias naming and structure bugs in js declarations

3005f18da5 Merge branch 'master' into fix-js-declaration-bugs

3bd49e49a7 Add another test case and change condition for ns merge to require signature or export content

ca5f764c8d Fix typo in comment
2019-10-30 13:24:42 -07:00
TypeScript Bot
28050d5c47 Cherry-pick PR #34789 into release-3.7 (#34812)
Component commits:
2e0b4513ef Add isIntersectionConstituent to relation key
isIntersectionConstituent controls whether relation checking performs
excess property and common property checks. It is possible to fail a
relation check with excess property checks turned on, cache the result,
and then skip a relation check with excess property checks that would
have succeeded. #33133 provides an example of such a program.

Fixes #33133 the right way, so I reverted the fix at #33213
Fixes #34762 (by reverting #33213)
Fixes #33944 -- I added the test from #34646

14d7a44c50 Merge branch 'master' into add-isIntersectionConstituent-to-relation-key

ea803620ec Update comments in test

0764275c30 Merge branch 'master' into add-isIntersectionConstituent-to-relation-key
2019-10-29 15:38:04 -07:00
Nathan Shively-Sanders
7d77ecbcff JSDoc type reference understands require with entity name (#34804)
* resolve require with entity name postfix

For example, `require("x").c`. This is the value equivalent of
`import("x").a.b.c`, but the syntax tree is not as nicely designed for
this purpose.

Fixes #34802

* Add bug number to test

* Add optional chain test
2019-10-29 15:17:02 -07:00
Daniel Rosenwasser
787ff340c5 Update LKG. 2019-10-28 16:48:33 -07:00
Daniel Rosenwasser
156ec62b17 Update version number to '3.7.2'. 2019-10-28 16:47:57 -07:00
TypeScript Bot
87befe826f Cherry-pick PR #34715 into release-3.7 (#34719)
Component commits:
4cb867bee8 Fix regression in mixin emit by removing unneeded line of code

e3cc5e9acf Double the test, double the fun
2019-10-28 16:44:44 -07:00
TypeScript Bot
1f3016fdb3 🤖 Cherry-pick PR #34743 into release-3.7 (#34781)
Component commits:
06fda263f8 Fix incorrect outDir usage instead of out

66f1a79c44 Handle symlinks of packages in mono repo like packages Fixes #34723
2019-10-28 16:44:03 -07:00
TypeScript Bot
17bd75d613 Cherry-pick PR #34779 into release-3.7 (#34782)
Component commits:
2e435ae3b0 Fix incorrectly looking for position in call/new expression arguments when looking for indentation of type arguments Fixes #32487

0bb1b40b1b Update src/services/formatting/smartIndenter.ts
Co-Authored-By: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2019-10-28 14:59:27 -07:00
TypeScript Bot
0965fc53a1 Update user baselines (#34769) 2019-10-28 12:46:40 -07:00
TypeScript Bot
9df593b1f3 Cherry-pick PR #34745 into release-3.7 (#34766)
Component commits:
07a371bbf6 Fix extract type on JS function params
2019-10-28 11:04:07 -07:00
TypeScript Bot
6317c901d7 Cherry-pick PR #34764 into release-3.7 (#34765)
Component commits:
ab9bc3a55a Fix type reference to merged prototype property assignment
The constructor function code path in the return type checking of
signatures needs to pass the *merged* symbol of the declaration to
getDeclaredTypeOfClassOrInterface. Other callers of
getDeclaredTypeOfClassOrInterface do this, or used an already-merged
symbol.

Fixes #33993
2019-10-28 10:58:15 -07:00
TypeScript Bot
330c8acda2 Cherry-pick PR #34702 into release-3.7 (#34710)
Component commits:
7be925173c Exclude ?? operator from true/false literal check in createFlowCondition

b9802166ae Accept new API baselines

3d4c14c5f8 Add tests

7362545e8c Accept new baselines

2d1af77839 Address CR feedback

8f0de27784 Accept new API baselines
2019-10-24 16:05:34 -07:00
TypeScript Bot
db419ff5ab Update user baselines (#34722) 2019-10-24 15:10:57 -07:00
TypeScript Bot
1ac8f40933 🤖 Cherry-pick PR #33847 into release-3.7 (#34720)
Component commits:
97dcbd3bb9 Avoid a crash with `@typedef` in a script file.
Scripts (as opposed to modules) do not have a symbol object. If a script
contains a `@typdef` defined on a namespace called `exports`, TypeScript
crashes because it attempts to create an exported symbol on the
(non-existent) symbol of the SourceFile.

This change avoids the crash by explicitly checking if the source file
has a symbol object, i.e. whether it is a module.

f9b7d6eaa8 Add usage of exports.SomeName typedef.

92dc69ddf0 Fix bug at bind site rather than in declare func
2019-10-24 14:30:58 -07:00
TypeScript Bot
cd0bfdd150 Update user baselines (#34711) 2019-10-24 14:03:36 -07:00
Andrew Casey
04d55bf05f Handle undefined from getPropertyNameForPropertyNameNode
...which can be returned when the property name is computed.

Part of #34404
2019-10-24 10:29:29 -07:00
TypeScript Bot
58bcb1e0dc Update user baselines (#34709) 2019-10-24 10:12:24 -07:00
TypeScript Bot
23d1b7b38a Cherry-pick PR #34706 into release-3.7 (#34708)
Component commits:
056a656937 Restore delayed merge check to getTypeFromJSDocValueReference
This is needed when a function merges with a prototype assignment. The
resulting *merged* symbol is a constructor function marked with
SymbolFlags.Class. However, the merge doesn't happen until
getTypeOfFuncClassEnumModule is called, which, in the
getTypeReferenceType code path, doesn't happen until
getTypeFromJSDocValueReference. That means the check for
SymbolFlags.Class is missed.

Previously, getTypeFromJSDocValueReference had a weird check
`symbol !== getTypeOfSymbol(symbol).symbol`, which, if true, ran
getTypeReferenceType again on `getTypeOfSymbol(symbol).symbol`. For
JS "aliases", this had the effect of dereferencing the alias, and for
function-prototype merges, this had the effect of ... just trying again
after the merge had happened.

This is a confusing way to run things. getTypeReferenceType should
instead detect a function-prototype merge, cause it to happen, and
*then* run the rest of its code instead of relying on try-again logic at
the very end. However, for the RC, I want to fix this code by restoring
the old check, with an additional check to make sure that #33106 doesn't
break again:

```ts
const valueType = getTypeOfSymbol(symbol)
symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol
```

I'll work on the real fix afterwards and put it into 3.8.

d1515f4ee0 Add bug number
2019-10-24 09:58:21 -07:00
TypeScript Bot
49301482a0 Cherry-pick PR #34683 into release-3.7 (#34705)
Component commits:
2aa257df80 getTypeFromJSDocValueReference: handle import types
Previously it only handled types whose declaration was from `require`,
but now it handles types whose reference is an import type as well.
2019-10-24 09:25:35 -07:00
TypeScript Bot
ce9ce20e02 Update user baselines (#34682) 2019-10-23 14:19:33 -07:00
typescript-bot
49dfb5ff55 Update LKG v3.7-rc 2019-10-23 13:22:52 -07:00
Wesley Wigham
7afaef1067 Cherry-pick PR #34679 into release-3.7
Component commits:
e0b98c6eae Do not consider element accesses which are neither statically bindable nor late bound as special assignments
2019-10-23 13:22:52 -07:00
TypeScript Bot
43fb7b44c0 Update user baselines (#34660) 2019-10-22 16:00:13 -07:00
Nathan Shively-Sanders
f21e9312e8
Cherry-pick PR #34649 into release-3.7 (#34657)
Component commits:
b6744812a0 Treat any mix of element/prop access as declaration in JS
Fixes #34642 but, notably, doesn't actually make the assignment into a
working declaration. It just fixes the crash.
2019-10-22 15:22:40 -07:00
TypeScript Bot
ea71ecfe22 Cherry-pick PR #34650 into release-3.7 (#34658)
Component commits:
6a6f4a666e Fix crash in assigning function with this ref to alias
2019-10-22 15:22:31 -07:00
Nathan Shively-Sanders
2b0d4600a7 Cherry-pick PR #34649 into release-3.7
Component commits:
b6744812a0 Treat any mix of element/prop access as declaration in JS
Fixes #34642 but, notably, doesn't actually make the assignment into a
working declaration. It just fixes the crash.
2019-10-22 21:47:42 +00:00
Daniel Rosenwasser
4b09fd707b Update LKG. 2019-10-21 14:50:14 -07:00
Daniel Rosenwasser
0d53d2fb6b Update version. 2019-10-21 14:49:04 -07:00
Daniel Rosenwasser
eea12682ee Merge remote-tracking branch 'origin/master' into release-3.7 2019-10-21 14:48:19 -07:00
Anders Hejlsberg
f84fd300b8
Merge pull request #34607 from microsoft/fix33490
Fix type inference regression
2019-10-21 12:50:38 -07:00
Anders Hejlsberg
ff6626f869
Merge pull request #34597 from microsoft/optionalChainControlFlow
More optional chaining control flow analysis
2019-10-21 12:36:07 -07:00
Daniel Rosenwasser
28028eb144
Extend the correct tsconfig.json. (#34615)
Extend the correct tsconfig.json.
2019-10-21 11:50:14 -07:00