Commit graph

18 commits

Author SHA1 Message Date
Anders Hejlsberg 0e905be42b
Index signatures for symbols and template literal strings (#44512)
* Switch index signature storage to 'indexInfos: IndexInfo[]' property

* Accept new baselines

* Remove another usage of IndexKind enum

* Update getIndexedAccessType and resolveMappedTypeMembers

* Accept new baselines

* Update grammar checking for index signatures

* Accept new baselines

* Consider all index signatures in mapped types and union types

* Accept new baselines

* Update getIndexType

* Accept new baselines

* Intersect multiple applicable index signatures

* Use getApplicableIndexInfo instead of hardwired string/number handling

* Update index signature relationship checking

* Report type for which index signature is missing

* Report type for which index signature is missing

* Accept new baselines

* Make 'number' index signatures consistently apply to numeric strings

* Accept new baselines

* Update fourslash test

* Revise index constraint checking

* Accept new baselines

* Update error messages

* Accept new baselines

* Update type inference from index signatures

* Update isKnownProperty

* Update contextual typing based on index signatures

* Accept new baselines

* Support union types in index signature declarations

* Accept new baselines

* Check duplicate index signatures / remove redundant template literals from unions with string

* Accept new baselines

* Include key type in diagnostic / check symbol-named properties

* Accept new baselines

* Minor fix

* Add tests

* Accept new baselines

* Add optimized findApplicableIndexInfoForName

* Accept new baselines

* Another place we don't need to obtain literal type for property name

* Accept new baselines

* Don't create literal types that are going to be discarded

* Individual maps for string, number, bigint, and enum literal types

* Remove ineffective optimizations

* Accept new baselines

* Permit intersections as key types in index signatures

* Index expression in element access is template literal context

* Add tests

* Accept new baselines

* Symbol index signatures from object literals with computed symbol properties

* Accept new baselines

* Add more tests

* Accept new baselines

* Implement Go To Definition for all applicable index signatures

* Add fourslash test

* Accept new API baselines
2021-06-21 11:25:42 -07:00
Anders Hejlsberg bf08d3bfc7 Fix linting issues 2019-09-23 06:14:52 -07:00
Anders Hejlsberg 643351ca2d Support deferred resolution of type arguments in type references 2019-08-23 09:54:55 -04:00
Anders Hejlsberg 1fd1de9625 More simplification + consistent use of getConstraintOfTypeParameter 2018-07-24 15:27:39 -07:00
Andy 8a3090bc35
Improve test for 'symbol.exports' (#25523)
* Improve test for 'symbol.exports'

* Remove SymbolFlags.HasExports and SymbolFlags.HasMembers

* Update baseline
2018-07-11 09:37:32 -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
Andy 8153397e91
Lazily compute signature type predicates (#17600)
* Lazily compute signature type predicates

* Use an instance of IdentifierTypePredicate to represent an unresolved type predicate

* Simplify `getMaybeTypePredicate`

* Invert representation of `resolvedTypePredicate`

* Remove `__unresolvedTypePredicate` type and remember to use `noTypePredicate` instead of `undefined` when in all `createSignature` calls

* Fix style of getTypePredicateOfSignature

* Use in createGetSymbolWalker

* Fix bugs for unions of type predicates

* Code review

* Make noTypePredicate purely an implementation detail of getTypePredictateOfSignature

* Add test

* Add test for #19642

* Add test with reversed order
2017-12-05 08:32:34 -08:00
Andy 74cbb827f9 Fix lint (#19387) 2017-10-20 14:12:24 -07:00
Andy 38905f46ce Minor cleanup to symbolWalker (#18549)
* Minor cleanup to symbolWalker

* Undo inlining
2017-09-22 14:07:07 -07:00
Andrew Casey 89447748d5 Reuse exiting getFirstIdentifier function 2017-08-22 11:33:36 -07:00
Andrew Casey e02da343db Retrieve type parameter constraint using getConstraintFromTypeParameter 2017-08-22 11:33:35 -07:00
Andrew Casey 1a20b6a7c3 Add support for walking IndexTypes, IndexedAccessTypes, and MappedTypes. 2017-08-22 11:33:35 -07:00
Andrew Casey d7ace2086f Fix copy-paste error 2017-08-22 11:33:34 -07:00
Andrew Casey 8cbf42cff5 Fix lint errors 2017-08-22 11:33:34 -07:00
Andrew Casey f2eacc6395 Use Maps to store visited types and symbols 2017-08-22 11:33:33 -07:00
Andrew Casey 801c1f70a2 Reshape SymbolWalker API
1. Expose visited types and symbols
2. Automatically reset before each walk
2017-08-22 11:33:32 -07:00
Wesley Wigham 2c8a5c40b8 Make SymbolWalker internal
...until required by an external consumer.
2017-08-22 11:33:32 -07:00
Wesley Wigham 053b915061 Rebase SymbolWalker change onto master
From PR #9847.
2017-08-22 11:33:32 -07:00