11702 Commits

Author SHA1 Message Date
Nathan Shively-Sanders
30994c86e4
Improve valueDeclaration for js module merges (#24707)
Nearly everything in a merge of JS special assignments looks like a
valueDeclaration. This commit ensures that intermediate "module
declarations" are not used when a better valueDeclaration is available:

```js
// File1.js
var X = {}
X.Y.Z = class { }

// File2.js
X.Y = {}
```

In the above example, the `Y` in `X.Y.Z = class { }` was used as the
valueDeclaration for `Y` because it appeared before `X.Y = {}` in the
compilation.

This change exposed a bug in binding, #24703, that required a change in
typeFromPropertyAssignmentOutOfOrder. The test still fails for the
original reason it was created, and the new bug #24703 contains a repro.
2018-06-06 11:11:15 -07:00
Nathan Shively-Sanders
d6250c8342
Fix circularity error when extending class in same JSContainer (#24710)
Do this by not widening properties of an object literal that are

1. JS initialisers
2. and not an object literal

These properties have types that will never widen, so the compiler
shouldn't ask for the types earlier than it strictly needs to.
2018-06-06 09:13:38 -07:00
Nathan Shively-Sanders
8d737ca959
Simplify parseJSDocIdentifierName (#24660)
* Simplify parseJSDocIdentifierName

It now always creates a missing node. The one place that depended on it
returning undefined, parseJSDocTypeNameWithNamespace, now returns
undefined before calling parseJSDocIdentifierName.

* Remove assert

It is adequately proven at compile time.
2018-06-05 14:30:37 -07:00
Wesley Wigham
d9b93903c0
Use more nodelike paths for import types when possible (#24610)
* Use more nodelike paths for import types when possible

* move functionality from services into compiler, fix with propert file/directory conflict handling

* mark suspect cast
2018-06-05 12:54:36 -07:00
Andy
735a46f838
If parsing a function type fails, parseTypeReference() to ensure something is returned (#24567)
* If parsing a function type fails, parseTypeReference() to ensure something is returned

* Avoid tryParse

* Add missing semicolon

* Don't check for undefined, check for missing type

* Don't set parameters undefined, set to missingList and return false

* Update API baselines

* Code review
2018-06-05 10:24:37 -07:00
Ron Buckton
fbeb58a147
Merge pull request #23893 from Microsoft/libReference
Adds 'lib' reference directives
2018-06-04 16:14:52 -07:00
Ron Buckton
666841264c Merge branch 'master' into libReference 2018-06-04 14:38:56 -07:00
Wesley Wigham
7eaa78846e
Visit the children of an import type/require call/dynamic import when looking for those (#24663) 2018-06-04 14:31:56 -07:00
Wesley Wigham
cbbf2e4e6f
Resolve aliases before using getTypereferenceType (#24594) 2018-06-04 14:19:41 -07:00
Sheetal Nandi
c3dcc83d4f
Merge pull request #24664 from Microsoft/builderAPIBreak
Fix the issue with createSemanticDiagnosticsBuilderProgram, createEmitAndSemanticDiagnosticsBuilderProgram and createAbstractBuilder not assignable to CreateProgram<T>
2018-06-04 13:35:40 -07:00
Nathan Shively-Sanders
7db4b1cbc7
Fix property assignment on aliases (#24659)
Aliases don't have valueDeclarations, which caused a crash when passed
to isJavascriptContainer before.
2018-06-04 13:34:23 -07:00
Andy
f9530d7e8f
Add 'parseOptionalJsdoc' helper (#24650) 2018-06-04 13:28:47 -07:00
Sheetal Nandi
e88305173d Fix the issue with createSemanticDiagnosticsBuilderProgram, createEmitAndSemanticDiagnosticsBuilderProgram and createAbstractBuilder not assignable to CreateProgram<T>
Fixes #24625
2018-06-04 13:03:57 -07:00
Nathan Shively-Sanders
34e68efdae
Template tag allows specification of constraints (#24600)
* Parse (and mostly support) template tag constraints

A bunch of tests hit the asserts I added though.

* Messy version is finished. Need to add a few tests

* Refactor to be smaller

* Small refactor + Add one test

* Another test

* Minor cleanup

* Fix error reporting on type parameters on ctors

* Simplify syntax of `@template` tag

This is a breaking change, but in my sample, nobody except webpack used the
erroneous syntax. I need to improve the error message, so
jsdocTemplateTag3 currently fails to remind me of that.

* Better error message for template tag

* Fix fourslash baselines

* Another fourslash update

* Address PR comments

* Simplify getEffectiveTypeParameterDeclarations

Make checkGrammarConstructorTypeParameters do a little more work
2018-06-04 11:42:46 -07:00
Anders Hejlsberg
75d0852d3e
Merge pull request #24637 from Microsoft/fixIndexedAccessSimplification
Fix indexed access simplification
2018-06-04 10:58:23 -07:00
Sheetal Nandi
d64608dc97
Merge pull request #24615 from Microsoft/jsonSourceMaps
Disable source maps and declaration emit for the json module
2018-06-04 10:48:43 -07:00
Wesley Wigham
779fa98475
Fix merge lexical environment to *always* respect prologue statements (#24602) 2018-06-04 10:34:38 -07:00
Andy
886377f8d3
Add autoCloseTag language service (#24543)
* Add autoCloseTag language service

* Change name to getJsxClosingTagAtPosition and return an object
2018-06-04 10:08:15 -07:00
Kitson Kelly
a9cb33db04
Treat host as possibly undefined for base64encode/base64decode
Fixes: #24638
2018-06-04 09:47:54 +10:00
Anders Hejlsberg
55d4d7b5c6 Simplify nested indexed access types 2018-06-03 08:57:15 -07:00
Anders Hejlsberg
667de4bbb9
Merge pull request #24627 from Microsoft/typeofFunction
Fix typeof x === "function" type guards
2018-06-02 18:46:52 -07:00
Anders Hejlsberg
0ff597c3a8 Improve typeof x === "function" narrowing for non-unions 2018-06-02 17:42:07 -07:00
David Sherret
7e0ed5ec4d Fix createProgram js docs. 2018-06-01 23:29:05 -04:00
Sheetal Nandi
d246c3c2bd Disable source maps and declaration emit for the json module
Fixes #24546
2018-06-01 18:31:58 -07:00
Andy
9be846e1f2
Fix bug when name resolution fails in a @typedef: Don't set lastLocation (#24585)
* Fix bug when name resolution fails in a @typedef: Don't set `lastLocation`

* Add noEmit to test
2018-06-01 16:49:54 -07:00
Wesley Wigham
1b6d9229f2
Visit super arguments even when no signature exists (#24591) 2018-06-01 14:14:56 -07:00
Wesley Wigham
f8503f2632
Include export specifiers in the list of syntactic defaults (#24549) 2018-06-01 10:40:30 -07:00
Andy
7e249ce721
Reduce size of span for unused declaration (revert #22388) (#24566) 2018-06-01 09:50:32 -07:00
Andy
d671c7ae96
getEditsForFileRename: Support directory rename (#24305)
* getEditsForFileRename: Support directory rename

* Code review

* Handle imports inside the new file/directory

* Document path updaters

* Shorten relative paths where possible

* Reduce duplicate code

* Rewrite, use moduleSpecifiers.ts to get module specifiers from scratch instead of updating relative paths

* Update additional tsconfig.json fields

* Add test with '.js' extension

* Handle case-insensitive paths

* Better tsconfig handling

* Handle properties inside compilerOptions

* Use getOptionFromName
2018-06-01 08:23:37 -07:00
Sheetal Nandi
997991fdcb
Merge pull request #24529 from Microsoft/suggestionDiagnosticsToken
Suggestion diagnostics to wire cancellationToken
2018-05-31 13:22:49 -07:00
Sheetal Nandi
fd242250c5
Merge pull request #24536 from Microsoft/trailingCommaInJson
Do not emit trailing comma in json module
2018-05-31 13:16:48 -07:00
Sheetal Nandi
eab21e5b77 Merge branch 'master' into suggestionDiagnosticsToken 2018-05-31 12:46:33 -07:00
Sheetal Nandi
1696da14f2 Do not emit trailing comma in json module
Fixes #24530
2018-05-31 12:40:08 -07:00
Mohamed Hegazy
e9dda76874
Merge pull request #24515 from Kingwl/esnext-symbol
add esnext symbol proposal
2018-05-31 12:23:01 -07:00
Mohamed Hegazy
86fe529f72
Merge pull request #24524 from a-tarasyuk/bug/24514-use-strict-prologue-emitted-in-json-files
Do not emit 'use strict' prologue in .json files with --alwaysStrict
2018-05-31 12:16:04 -07:00
Nathan Shively-Sanders
d187de2076
Better JS container binding (#24367)
* Static assignments to class expressions work

* Bind static properties of functions too

Also update SymbolLinks in getTypeOfFuncClassEnumModule so that the
type gets cached correctly.

* Remove initializer handling:obj literals+type lookup

Also include a couple of improved baselines

* Fix 1-nested js containers:binding+cross-file merge

* Consolidate check into one utility

The utility is horrible and needs to change, but at least it's in one
place.

Next step is to make the utility like getDeclarationOfAlias, except
getDeclarationOfJSAlias.

* Defaulted assignments now (mostly) work

* Default assignment definitely work, and IIFEs kind of do

* n-nested undeclared containers now seem to work

Merging even seems to work ok.

* Handle prototype+prototype property assignments

Perhaps in the wrong way. I have an idea how to simplify them.

* Remove prototype special-case

1. It's not completely removed; the checker code in
getJavascriptClassType needs to be fixed, among other places.
2. I didn't actually remove the code so that it will be easier to see
what used to be there on Monday.

Regardless, the code will be much simpler and seems to be mostly
improved with very little work so far.

* Allow more merges+accept baselines

* Update more baselines

* Fix js initializer check in bindPropertyAssignment

* Fix codefixes

* Rest of strictNullChecks cleanup + other cleanup

1. Remove a few TODOs
2. Remove extraneous SymbolFlag
3. Simplify isSameDefaultedName

* Binder cleanup

* Checker cleanup

* Almost done with utilities cleanup

* Utilities cleanup

* Require js initializer to be (1) JS (2) initializer

Change getDeclarationOfJSInitializer to require that the provided js
initializer be in a javascript file, and that it is the initializer of
the retrieved declaration.

* Use getSymbolOfNode instead of accessing symbol directly

* Ugh. Start over with just test cases

* Handle additional cases in getTypeOfVariableOrParameterOrProperty

These are cases in a really embarrassing check, in which we admit that
the symbol flags steered us wrong and switch to
getTypeOfFuncClassEnumModule instead (which never asserts).

* Add test case for #24111

* Address PR comments
2018-05-31 11:41:26 -07:00
Sheetal Nandi
b0f039c9e2 Make suggestion diagnostics to wire cancellationToken
This especially needed if its a js file without the ts-check, the file wont be typechecked in getSemanticDiagnostics
Fixes part of #19458
2018-05-31 10:47:17 -07:00
Alexander T
7ef7f907b9 Do not emit 'use strict' prologue in .json files with --alwaysStrict 2018-05-31 20:28:53 +03:00
Ron Buckton
b4e113b94e Merge branch 'master' into libReference 2018-05-31 10:02:08 -07:00
Ron Buckton
7de55fbb7e PR Feedback 2018-05-31 09:50:51 -07:00
王文璐
7910bbdccb add esnext symbol proposal 2018-05-31 13:30:31 +08:00
Wesley Wigham
576a733378
For type emit, walk non-parent containers when those containers have aliases leading to the target (#24507) 2018-05-30 17:52:59 -07:00
Wesley Wigham
04379d548c
Lookup type arguments correcly for taged templates when checking generic arity (#24496) 2018-05-30 15:03:04 -07:00
Nathan Shively-Sanders
cdfa63aa40
Fix exported type resolution in commonjs (#24495)
* Fix resolution of exported types in commonjs

It is fine to resolve the types of exported classes in ES6:

```js
export class C {
}
var c = new C()
```

But not for commonjs exported classes:

```js
module.exports.C = class {
}
var c = new C() // should error
```

Fixes #24492

* All jsdoc type aliases are available locally in commonjs modules

* Check that location isSourceFile before commonJsModuleIndicator
2018-05-30 14:12:38 -07:00
Andy
43bf039a94
Add refactor to convert namespace to named imports and back (#24469)
* Add refactor to convert namespace to named imports and back

* Add tests and comments

* Code review

* Handle shorthand property assignment and re-export

* Don't use forEachFreeIdentifier

* Fix rename after "."
2018-05-30 14:11:53 -07:00
Andy
239dde8ff1
Fix cast: location may be a SourceFile (#24498) 2018-05-30 13:37:32 -07:00
Sheetal Nandi
2226cd6a99
Merge pull request #24471 from Microsoft/watchInSiblingOfRoot
Instead of creating filter for subDirectories to watch in the ancestor directory of root, watch those subDirectories for failed lookup locations
2018-05-30 11:12:23 -07:00
Anders Hejlsberg
a8a31ed508
Merge pull request #24439 from Microsoft/unknownType
New 'unknown' top type
2018-05-30 10:22:02 -07:00
Andy
675e21203e
Improve template literal tests (#24359)
* Improve template literal tests

* Inline isTemplateLiteralToken where possible
2018-05-30 10:21:00 -07:00
Nathan Shively-Sanders
22cdff59e4
Better fix for bogus duplicate identifier in module exports (#24491) 2018-05-30 09:59:14 -07:00