11651 Commits

Author SHA1 Message Date
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
Ron Buckton
fc3e88e26f
Merge pull request #24481 from Microsoft/fix24173
Fix async generator return as well
2018-05-30 09:43:00 -07:00
Andy
5e2c7ffce6
isValidMethodAccess: use getTypeOfPropertyOfType instead of getTypeOfFuncClassEnumModule (#24488) 2018-05-30 09:12:24 -07:00
Anders Hejlsberg
86643902b2 Rename unknownType to errorType in merged code 2018-05-30 08:17:09 -07:00
Anders Hejlsberg
e22a9d6fc1 Merge branch 'master' into unknownType 2018-05-30 07:45:10 -07:00
Anders Hejlsberg
6b1c84e84a Remove eager resolution of distributive conditional types 2018-05-29 17:55:31 -07:00
Ron Buckton
6f7715444f Fix async generator return as well 2018-05-29 17:54:59 -07:00
Ron Buckton
c224a824f3 Do not await iterated value in for-await-of 2018-05-29 15:33:43 -07:00
Sheetal Nandi
939e3e4780 Instead of creating filter for subDirectories to watch in the ancestor directory of root, watch those subDirectories for failed lookup locations
Before this change, when failed lookup location didnt fall in root directory,
we tried to find the ancestor directory of the rootDirectory to watch.
We also created subDirectory map for the directories that are being watched so we dont go through invalidation if path is unwanted directory
With this change, we will watch those subdirectories instead of root. On windows node supports file system level recursive watching so the earlier approach was better because we reduced number of watches created
But on other os, since node doesnt support it, we create the watches for existing folders outselves, so earlier approach becomes expensive.
This should be better compromize to satisfy both types of OS.
Fixes #24434
2018-05-29 14:49:19 -07:00
Nathan Shively-Sanders
36c580378f
Fix duplicate identifier error with module.exports (#24466)
A bug in checkSpecialAssignment added bogus duplicate identifier errors
when using module.exports assignment to export a class. This commit
fixes that.
2018-05-29 14:29:48 -07:00
Nathan Shively-Sanders
15bfaf1cf6
Skip IntrinsicAttributes elaboration in JSX errors (#24461)
* Skip IntrinsicAttributes elaboration in JSX errors

Do not issue an error message for a source type that comes from JSX
attributes and a target type that is an intersection containing
IntrinsicAttributes or IntrinsicClassAttributes. This will make error
messages simpler and less confusing.

Note:
1. There will always be elaboration under the skipped message, so this
won't elide errors completely.
2. Rarely (once in the tests) the intersection type will have more that
one non-Intrinsic* member. However, these additional members don't
provide useful information either, so it's fine to skip them.

* Add test of IntrinsicAttributes error

* Fix indentation in test
2018-05-29 14:00:26 -07:00
Ron Buckton
6657df47f0 Fix return and throw propagation for yield* 2018-05-29 12:56:46 -07:00
Anders Hejlsberg
074961f303 keyof unknown should be never 2018-05-29 12:54:00 -07:00
Anders Hejlsberg
a83653ed99 Add new diagnostic 2018-05-27 15:43:44 -07:00
Anders Hejlsberg
353802c140 Check we have non-unknown where we require non-nullable 2018-05-27 15:43:31 -07:00
Anders Hejlsberg
79e7700c6b { [P in unknown]: XXX } should resolve to { [x: string]: XXX } 2018-05-27 10:25:13 -07:00
Anders Hejlsberg
9e4d19f2ef Fixes to keyof and narrowing by typeof check 2018-05-26 18:18:08 -07:00
Anders Hejlsberg
b20925ad40 'null' and 'undefined' are bottom types in non-strictNullChecks mode 2018-05-26 12:09:18 -07:00
Anders Hejlsberg
2003b2a3e2 Implement 'unknown' type in checker 2018-05-26 09:53:07 -07:00
Anders Hejlsberg
03f464f433 Add 'unknown' keyword to scanner/parser/emitter 2018-05-26 08:51:09 -07:00
Anders Hejlsberg
8f193b40ee Free up one bit in TypeFlags 2018-05-26 08:29:30 -07:00
Anders Hejlsberg
07a696f785 Rename existing unknownType to errorType 2018-05-26 08:07:25 -07:00
Mohamed Hegazy
a7a68d9591 Merge branch 'fix-es5-export-class-name-object' of https://github.com/Kingwl/TypeScript into Kingwl-fix-es5-export-class-name-object 2018-05-25 15:45:31 -07:00
王文璐
7f127de89e remove invalid check 2018-05-25 09:36:16 +08:00
Wesley Wigham
8f9c0861bc
Use external aliases in quickinfo and signature help return types (#24391)
* Dont include import types in quick info type names

* Add UseAliasDefinedOutsideCurrentScope flag to LS operations which were missing it
2018-05-24 15:19:57 -07:00
Nathan Shively-Sanders
e250942d6a
Disallow nested object param syntax in callback tag (#24392)
* Callback tag:Disallow nested-object-param syntax

Previously this caused a crash in parsing. If/when we want to support
this syntax, we will need to fix this crash.

* Update baselines
2018-05-24 15:11:33 -07:00
Elizabeth Dinella
13734e7d68
Fix for issue #6154 - overriding methods with properties in the derived class (#24343)
* Fix to issue 6154 - Overriding a method with a property in the derived class should not cause a compiler error

* new baselines

* fixed deleted baselines
2018-05-24 14:12:13 -07:00
Sheetal Nandi
51058b56e5 Do not trigger invalidation if emitted file is in declarationDir 2018-05-24 13:36:52 -07:00
Wesley Wigham
4be4e56579
Hoisted declarations should occur after prologue directives (#24386) 2018-05-24 12:49:02 -07:00
Andy
ee8337d8e4
Minor cleanups in importFixes (#23995) 2018-05-24 07:46:39 -07:00
王文璐
d5239cdf6a fix ambient context 2018-05-24 18:20:54 +08:00
kingwl
cb2be44d02 fix export class declare with name object targeting es5 (#17494) 2018-05-24 18:16:38 +08:00
Mohamed Hegazy
10ac8b47e5
Merge pull request #22022 from Kingwl/enum-eval-div-zero
disallow nan and infinity in enum member
2018-05-23 15:32:35 -07:00
Wenlu Wang
4606709672 add code fix convert to mapped object type (#24286)
* add code fix convert to mapped object type

* add support for type literal and improve test

* fix typo

* add support for heritageClauses

* only determine declaration is not class
2018-05-23 14:09:49 -07:00
Andy
5983c45e24
Fix typo: seperate -> separate (#24338)
* Fix typo: seperate -> separate

* update tests
2018-05-23 09:36:17 -07:00
Wesley Wigham
0102f8050c
Check for keyof constraint type instead of syntactic check (#24098)
* Check for keyof constraint type instead of syntactic check

* Readopt older candidateType check, even though it shouldnt really matter

* OK. Just use maybetypeOfKind

* Remove redundant boolean check
2018-05-22 16:58:31 -07:00
Wesley Wigham
8b8cd31784
Use unknown serialization kind when type symbol isnt resolved (#24332)
* Use unknown serialization kind when type symbol isnt resolved

* Add test for the isolated modules case
2018-05-22 16:56:12 -07:00
Andy
e53e56cf82
Enable '--strictNullChecks' (#22088)
* Enable '--strictNullChecks'

* Fix API baselines

* Make sys.getEnvironmentVariable non-nullable

* make properties optional instead of using `| undefined` in thier type

* reportDiagnostics should be required

* Declare firstAccessor as non-nullable

* Make `some` a type guard

* Fix `getEnvironmentVariable` definition in tests

* Pretend transformFlags are always defined

* Fix one more use of sys.getEnvironmentVariable

* `requiredResponse` accepts undefined, remove assertions

* Mark optional properties as optional instead of using `| undefined`

* Mark optional properties as optional instead of using ` | undefined`

* Remove unnecessary null assertions

* Put the bang on the declaration instead of every use

* Make `createMapFromTemplate` require a parameter

* Mark `EmitResult.emittedFiles` and `EmitResult.sourceMaps` as optional

* Plumb through undefined in emitLsit and EmitExpressionList

* `ElementAccessExpression.argumentExpression` can not be `undefined`

* Add overloads for `writeTokenText`

* Make `shouldWriteSeparatingLineTerminator` argument non-nullable

* Make `synthesizedNodeStartsOnNewLine` argument required

* `PropertyAssignment.initializer` cannot be undefined

* Use one `!` at declaration site instead of on every use site

* Capture host in a constant and avoid null assertions

* Remove few more unused assertions

* Update baselines

* Use parameter defaults

* Update baselines

* Fix lint

* Make Symbol#valueDeclaration and Symbol#declarations non-optional to reduce assertions

* Make Node#symbol and Type#symbol non-optional to reduce assertions

* Make `flags` non-nullable to reduce assertions

* Convert some asserts to type guards

* Make `isNonLocalAlias` a type guard

* Add overload for `getSymbolOfNode` for `Declaration`

* Some more `getSymbolOfNode` changes

* Push undefined suppression into `typeToTypeNodeHelper`

* `NodeBuilderContext.tracker` is never `undefined`

* use `Debug.assertDefined`

* Remove unnecessary tag

* Mark `LiteralType.freshType` and `LiteralTupe.regularType` as required
2018-05-22 14:46:57 -07:00
Wesley Wigham
3fe946df78
Use symbolToTypeNode for class & interface references (#24330)
* Use merged symbols when calculating qualification, use symbolToTypeNode

* Accept baselines
2018-05-22 14:09:45 -07:00
Andy
7106a587cc
Add type for diagnostics where location is defined (#23686)
* Add type for diagnostics where location is defined

* getSemanticDiagnostics may return global diagnostics

* Reduce array creation
2018-05-22 11:01:18 -07:00
Anders Hejlsberg
a5029e3d4e
Merge pull request #23794 from Microsoft/fixDiscriminatedContextualType
Fix discriminant checking in contextual types
2018-05-22 10:35:29 -07:00
Andy
982c8d0af9
Add suggestion diagnostics for unused label and unreachable code (#24261)
* Add suggestion diagnostics for unused label and unreachable code

* Always error on unused left hand side of comma
2018-05-22 07:56:29 -07:00
Anders Hejlsberg
f52c4af448
Merge pull request #24310 from Microsoft/nonWideningLiteralInferences
Non-widening literal type inferences
2018-05-22 06:56:34 -07:00
Mohamed Hegazy
a9e89ce3f1
Merge pull request #24180 from Microsoft/updateVersion
Update version
2018-05-21 17:18:39 -07:00