Commit Graph
100 Commits
Author SHA1 Message Date
Wesley Wigham e9e7a9d49a Fix #51623 (#51762)
* Fix #51623

* Revert newline changes
2022-12-05 12:48:11 -08:00
Wesley Wigham b23b29b71b Use formatting newline rather than host newline in extractType (#51764) 2022-12-05 12:47:36 -08:00
Wesley Wigham b4024a5506 Preserve input key style when writing mapped type keys in declaration emit (#50781) 2022-11-18 12:54:12 -08:00
Wesley Wigham a3092c798a Preserve alias symbols on references to type aliases via imports (#51152)
* Preserve alias symbols on references to type aliases via imports

* Fix lint
2022-11-17 21:25:31 -08:00
Wesley Wigham d83a5e1281 Fix nightly post-#50528 merge (#51432) 2022-11-07 13:15:51 -08:00
Wesley Wigham 4d15bb16e1 Fix #50869, only cache calculated type for non-context sensitive parameters (#50976)
* Fix #50869, only cache calculated type for non-context sensitive parameters

* Simplify check, update comment
2022-10-31 17:24:51 -07:00
Wesley Wigham bdcc240d68 Remove bug-causing carve-out in conditional type instantiation that hopefully is no longer required (#51151) 2022-10-13 10:58:42 -07:00
Wesley Wigham f46a680863 Remove error message in node16 (#50673) 2022-09-07 18:47:39 -07:00
Wesley Wigham 488d0eebd0 Retain name and propertyName in declaration emit copies of binding patterns if property name is a keyword (#50537)
* Retain name and propertyName in declaration emit copies of binding patterns if property name is a keyword

* Accept baselines

* Remove out of date file
2022-08-30 09:03:02 -07:00
Wesley Wigham 05d7d6bb12 Unify default import resolution across specifier target codepaths (#49814)
* Unify default import resolution across specifier target codepaths

* Use differing type aliases, per request
2022-08-19 02:25:41 -07:00
Wesley Wigham e989d840f1 Forward intersectionState flag when comparing indexed access constraints (#50261) 2022-08-15 16:10:32 -07:00
Wesley Wigham 9872184483 Remove dependence on module compiler option to consider mts/cts files always modules (#49815) 2022-07-06 13:26:36 -07:00
Wesley Wigham eb430f27ea More documentation on the impliedNodeFormat SourceFile field (#49816) 2022-07-06 13:25:58 -07:00
Wesley Wigham 0f868035af Constrain infer type parameters made to preserver distributivity for inlined homomorphic mapped types (#49793) 2022-07-06 09:32:37 -07:00
Wesley Wigham 4c34f2c792 Fix mapper used to instantiate distributive conditional manufactured in declaration emit (#49737) 2022-06-30 15:03:25 -07:00
Wesley Wigham 52f4055174 For missing constraint quickfix insert position, Use node name end rather than related span end (#49673) 2022-06-29 11:46:42 -07:00
Wesley Wigham 5c4caafc2a Allow nongeneric string mapping types to exist (#47050)
* Allow nongeneric string mapping types to exist

* Accept baseline

* Recusive membership testing function

* Fix lint

* Add @DanielRosenwasser's comment
2022-06-16 17:02:31 -07:00
Wesley Wigham ccd8b1d27e Allow exports map entries to point at .ts source files (#48563)
* Probably works

* Add tests

* Update baselines for module option rename
2022-06-15 11:23:26 -07:00
Wesley Wigham ba38fe1df2 Expand constraint suggestion related span and add quick fix (#49481)
* Expand constraint suggestion related span and add quick fix

* Remove circular constraint suggestions

* Add error code

* Style feedback and new error code in quickfix
2022-06-15 10:35:51 -07:00
Wesley Wigham eb4b8a4d2e Handle this in isEntityNameVisible (#49521) 2022-06-15 10:15:19 -07:00
Wesley Wigham ce639352bb Serialize inaccessible class declarations the same as class expressions in declaration emit (#49440) 2022-06-08 16:33:09 -07:00
Wesley Wigham 86ff3f6fec Give cjs export assigned types an alias symbol (#49407) 2022-06-08 16:32:18 -07:00
Wesley WighamandDaniel Rosenwasser 3ccbe804f8 Expose import mode calculation functions (#49360)
* Expose import mode calculation functions

* Make `SourceFileImportsList` internal again.

* Accepted API baselines.

* Fix lints.

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2022-06-02 18:06:50 -07:00
Wesley Wigham 19b22844d8 Use node's algorithm for calculating the longest matching export/import pattern (#49361) 2022-06-02 15:43:26 -07:00
Wesley Wigham bf5acb5c4d Issue serialization error when attempting to serialize a late-bound name from a mapped type (#49221) 2022-05-31 15:36:13 -07:00
Wesley Wigham 67673f324d moduleDetection: auto makes cjs files parse as modules, module: node sets moduleDetection: force (#49268) 2022-05-26 16:49:55 -07:00
Wesley Wigham 194a2aea0d Key validity of import=require in module: node off of module and not target (#49222) 2022-05-24 03:33:23 -07:00
Wesley Wigham f84ec3e8b4 Fix type parameter comparability to consistently allow comparisons on unconstrained type parameters (#48861)
* Fix type parameter comparability to consistently allow comparisons on unconstrained type parameters

* Less elaboration, non-strict-mode fix
2022-05-09 12:22:00 -07:00
Wesley Wigham 8e433cda3d Allow export map entries to remap back to input files for a program (#47925)
* Allow export map entries to remap back to input files for a program

* Fix file casing issues on windows

* Implement abiguity error, doesnt quite work

* Refine selection logic in error case to use getCommonSourceDirectory, add more tests
2022-05-05 12:53:56 -07:00
Wesley Wigham ce487e4fd3 Fix meta property symbol lookup (#48773) 2022-04-19 17:57:06 -07:00
Wesley Wigham 12c4ea8542 Fix semantic merge conflict 2022-04-08 12:15:50 -07:00
Wesley Wigham f30ce1ff8f Update update-package-lock.yaml
12 -> 14
2022-04-08 11:16:49 -07:00
Wesley Wigham 5e721d979d Update update-lkg.yml
12 -> 14
2022-04-08 11:16:27 -07:00
Wesley Wigham 76e6e46d51 Update sync-branch.yaml 2022-04-08 11:15:41 -07:00
Wesley Wigham 6bcc53bbce Update set-version.yaml 2022-04-08 11:15:21 -07:00
Wesley Wigham b246dee2b8 Update nightly.yaml 2022-04-08 11:14:50 -07:00
Wesley Wigham a33e7acfc8 Update ci.yml
Update node versions
2022-04-08 11:14:11 -07:00
Wesley Wigham 8e447462a6 Update accept-baselines-fix-lints.yaml
12 -> 14
2022-04-08 11:13:37 -07:00
Wesley Wigham ee82068989 Update new-release-branch.yaml
12 -> 14
2022-04-08 11:13:13 -07:00
Wesley Wigham 1df80737a1 Update release-branch-artifact.yaml
12 -> 14 (we have odd test errors on 12 that aren't worth debugging)
2022-04-08 11:12:29 -07:00
Wesley Wigham ca96d2e246 Fix semantic merge conflict 2022-04-07 14:14:11 -07:00
Wesley Wigham 4d2fb5407c Preserve the distributivity of inlined conditional types in declaration emit (#48592) 2022-04-06 17:21:46 -07:00
Wesley Wigham 94d33ba85d Ensure late painted statements are only transformed once, so inner substitutions are consistently read (#48558)
* Ensure late painted statements are only transformed once, so inner substitutions are consistently read

* PR suggestion

* Fix lint
2022-04-06 16:36:42 -07:00
Wesley Wigham 9d2f72b285 Remove nightly-only flagging for nodenext features (#48555) 2022-04-04 14:07:32 -07:00
Wesley Wigham a5dae37943 Prevent looking up symbol for as const from triggering an error (#48464) 2022-03-28 12:53:36 -07:00
Wesley Wigham 8907d7a675 Fix test build post-LKG (#48403) 2022-03-24 12:55:27 -07:00
Wesley Wigham 8cd4b7a5da Make the unconstrained type parameter and {} assignability rule not apply under strictNullChecks (#48366)
* Make the unconstrained type parameter and {} assignability rule not apply under strictNullChecks

* Fix lint, PR feedback
2022-03-23 16:22:40 -07:00
Wesley Wigham b5a3a058f5 Merge diagnosticsProducing and nonDiagnosticsProducing checkers into a single checker supporting lazy diagnostics (#36747)
* Merge diagnosticsProducing and nonDiagnosticsProducing checkers into a single checker supporting lazy diagnostics

* Fix lint
2022-03-23 16:21:06 -07:00
Wesley Wigham 26c701c351 Fix document registry cache key calculation for paths compiler option (#48389)
* Fix document registry cache key calculation for `paths` compiler option

* PR feedback
2022-03-23 15:57:39 -07:00
Wesley Wigham 7f652509b6 Handle JS synthetic rest args in contextual parameter assignment (#48263)
* Handle JS synthetic rest args in contextual parameter assignment

* Limit fixing to only unannotated js rest parameters

* Minimize test

* Add annotated version

* Remove explicit CheckFlags.RestParameter check since apparently not all rest parameters are CheckFlags.RestParameter
2022-03-16 11:04:07 -07:00
Wesley Wigham 92bc2ddc3c Consistently avoid pulling on the source return type when the target return type is any (#47306) 2022-03-15 18:16:05 -07:00
Wesley Wigham 93c3a30edc Add assertion on invalid cache set (#43845) 2022-03-11 10:57:22 -08:00
Wesley Wigham d1fa945261 Add moduleDetection compiler flag to allow for changing how modules are parsed (#47495)
* Add moduleDetection compiler flag to allow for changing how modules are parsed

The default setting is 'auto', where JSX containing files under react-jsx and react-jsxdev are
always parsed as modules, and esm-format files under module: node12+ are always parsed as modules,
in addition to the 'legacy' detection mode's conditions for other files. (Declaration files are exempt from
these new conditions)

The 'legacy' mode preserves TS's behavior prior to the introduction of this flag - a file is
parsed as a module if it contains an import, export, or import.meta expression.

In addition, there is a 'force' mode that forces all non-declaration files to be parsed as modules.
(Declaration files are still only modules if they contain a top-level import or export.)

This technically breaks the parser API, but it's kinda-sorta backwards compatible so long
as you don't need the functionality associated with more recent compiler flags.

* Fix post-merge lint

* Rename function

* Update default value documentation

* PR feedback

* Fix lint and typo
2022-03-11 10:36:00 -08:00
Wesley Wigham 3f63804878 Make direct assignments to cjs exports considered literal contexts (#39816)
* Make direct assignments to cjs exports considered literal contexts

* Style feedback from PR

* Trailing whitespaaaaace
2022-03-09 13:27:39 -08:00
Wesley Wigham f76452cb27 Fix conditional type type parameter leak (#31455)
* Fix conditional type type parameter leak

* Monkey with comment text per code review

* Conditionally clone type param

* Reuse input array and avoid making mapper where possible
2022-03-09 13:25:14 -08:00
Wesley Wigham fc82c67357 Don't eagerly simplify reducible generic union index types (#46812) 2022-03-09 12:02:11 -08:00
Wesley Wigham ea4791d4d7 Preserve the homomorphism of inlined mapped types in declaration emit (#48091) 2022-03-09 10:31:54 -08:00
Wesley Wigham c70be8b501 Handle nonmaster branches in user suite tests (#48128)
* Handle nonmaster branches in user suite tests

* Fix remaining changed default branches, vscode & vue-next docker install scripts

* NPM reformats these on install now, comitting so it doesnt need to be ignored

* Accept current user suite baselines

* Fix many trivially fixable user suite tests
2022-03-09 10:31:16 -08:00
Wesley Wigham bae0f50818 Fix import assertion occurrences crash and make import assertion parsing more generous (#47535) 2022-01-20 14:08:47 -08:00
Wesley Wigham 97a7901f26 Use features for selected module resolution rather than all features for type reference directives, since they can add restrictions to resolutions (#47007) 2021-12-04 04:24:28 -08:00
Wesley Wigham 0bf97296d6 Allow nightly-only flags in -insiders builds (#46829) 2021-11-16 12:53:37 -08:00
Wesley Wigham 4a065f524c Fix RWC missing file detection (#46673) 2021-11-09 10:41:18 -08:00
Wesley Wigham d53630fac3 Make specifier generation from export map information conditional on module resolution mode (#46670) 2021-11-03 13:10:44 -07:00
Wesley WighamandAndrew Branch de23842e45 Allow import assertions on esm imports under module: nodenext (#46630)
* Allow import assertions on esm imports under module: nodenext

* Changes to copy

Co-authored-by: Andrew Branch <andrew@wheream.io>
2021-11-02 15:34:37 -07:00
Wesley Wigham 28e3cd3a80 Add error on new module/moduleResolution modes when used in non-nightly TS (#46557)
* Add error on new module/moduleResolution modes when used in non-nightly TS

* Update diagnostic
2021-10-29 11:46:19 -07:00
Wesley Wigham abfd537503 Support resolveJsonModule in new module modes (#46434)
* Support resolveJsonModule in new module modes

* Formatting feedback
2021-10-27 12:30:06 -07:00
Wesley Wigham 2c7b13b830 Fix explainFiles on files under nodenext with types references (#46367)
* Fix explainFiles on files under nodenext with types references

* Fix explainFiles crash on module nodenext
2021-10-14 17:00:55 -07:00
Wesley Wigham 1c5d4e1740 Pass symbol under inspection into checkIndexConstraints (#46350) 2021-10-13 17:04:33 -07:00
Wesley Wigham ac345849e3 Set impliedNodeFormat on sourceFiles maufactured in watch mode (#46349) 2021-10-13 17:04:13 -07:00
Wesley Wigham 713afe2227 Set import mode on synthetic imports (#46327) 2021-10-12 16:23:37 -07:00
Wesley Wigham 82822fc1e9 Use a binary search when looking for the token at a given position (#46250) 2021-10-07 15:06:18 -07:00
Wesley Wigham 7108646713 Fix extension automatic script kind detection for new extensions (#46205)
* Fix extension script kind detection for new extensions

* Accept (correct) changes to existing baselines affected by correct ScriptKind detection
2021-10-06 13:23:54 -07:00
Wesley Wigham ed9c522fd6 Accept new moduleResolution options on commandline (#46239) 2021-10-06 13:17:27 -07:00
Wesley Wigham 1cee9731d2 Properly support scoped package self name lookups (#46212) 2021-10-05 12:41:44 -07:00
Wesley Wigham 47cd4d3ecf Only set package data map under watch mode (#46211) 2021-10-05 11:13:26 -07:00
Wesley Wigham a0cf126513 Limit package.json realpath lookup to only successful resolutions (#46209) 2021-10-05 10:24:08 -07:00
Wesley Wigham a02a7ab8e9 Follow and respect export maps when generating module specifiers (#46159)
* Follow and respect export maps when generating module specifiers

* Type baseline updates from master merge
2021-10-01 13:54:07 -07:00
Wesley Wigham ccc19092ff Modify synthetic default generation code for dual-mode module resolution (#46156) 2021-10-01 09:18:44 -07:00
Wesley WighamandAndrew Branch 612c92d603 Track source and target relationship stack depth seperately, only increase on change in value (#41821)
* Track source and target relationship stack depth seperately, only increase on change in value

* Add baselines for test from #43485

* Bail on unwrapping conditional constraints on the source side when the source conditional is already known to be spooling out of control

* More usage of isDeeplyNestedType to block _specifically_ conditional recursion on only one side

* Negative cases of getNarrowedType that match the exact type should be filtered out, even when generic

* Add test and fix for #44404

* Swap to manually specifying left and right recursion

* Rename Left -> Source, Right -> Target

Co-authored-by: Andrew Branch <andrew@wheream.io>
2021-09-30 16:58:40 -07:00
Wesley Wigham 8d5c197f99 keyof should always include remapped keys (#45923)
* Loosen check in getIndexTypeForMappedType to directly map property names when any indexy type is present

* Handle homomorphic mappings better in keyof, add specific relationship rule for relating generic keyof MappedType to handle remapped keys

* Remove trailing whitespace
2021-09-27 19:10:02 -07:00
Wesley Wigham 586b0d5011 moduleResolution: node12 support (#45884)
* Initial support for module: node12

* Add allowJs and declaration emit enabled tests

* Fix typos

* cts, mts, cjs, mjs, etc extension support

* Fix watch of files whose intepretation changes due to a package.json update

* Minor PR feedback

* Adjust error message

* Initial import/export/self-name support

* Accept new error codes

* TypesVersions support in export/import map conditions

* Fix import suggestion and autoimport default extensions under new resolution modes

* Add tests for import maps non-relative name lookup feature

* Fix isDeclarationFileName for .d.mts and .d.cts

* Preserve new extensions when generating module specifiers

* Fix spurious implict any suggestion caused by file ordering bug and optimize import name format detection by relying on parents being set

* Fix a bunch of incremental bugs that dont repro under fourslash for some reason

* Accept updated baseline

* Always include extensions on completions for cjs/mjs style imports

* String completion relative import suggestions respect the mode of the import when choosing if they provide extensions

* Style feedback

* Change diagnostic case
2021-09-24 14:25:59 -07:00
Wesley Wigham f598076e68 Close package json watches in watch mode on close (#45642) 2021-08-30 12:53:26 -07:00
Wesley Wigham 68eb1a551f Use getFileAndProject in session provideInlayHints to ensure language service updates are applied (#45394) 2021-08-10 11:48:35 -07:00
Wesley Wigham 7669bfba15 Actually instantiate the type of the annotation used for contextual types (#45285) 2021-08-02 12:44:56 -07:00
Wesley Wigham d0efe9065e Dont swallow declaration emit errors when issued on nodes without names (#44995) 2021-07-16 10:30:22 -07:00
Wesley Wigham 8268f2adec Avoid bogus circularity error on context sensitive constructor property assignments (#44601)
* Avoid bogus circularity error on context sensitive constructor property assignments

* Add JS case and ensure its fixed
2021-07-15 17:06:56 -07:00
Wesley Wigham 8e855d140b Watch mode watches for changes in package.json files used in resolution (#44935)
* watch mode watches for changes in package.json files used in resolution

* Pathify result of realpath

* Actually accept pathified baselines
2021-07-12 17:23:08 -07:00
Wesley Wigham 130e16d73b Add missing JSXSpreadAttribute case to JSX completion logic (#44514) 2021-06-10 10:01:25 -07:00
Wesley Wigham 09a21ce7c6 Consider inferences between mapped type templates lower priority (#44126) 2021-05-28 21:07:39 -07:00
Wesley Wigham 7c31d97cbf Move string trim methods from utilities to core (#44308) 2021-05-27 14:20:23 -07:00
Wesley WighamandDavid Michon fcabb5c0cc Simplify or optimize regexes with polynomial time worst cases (#44197)
* Simplify or optimize regexes with polynomial time worst cases

* PR feedback & cleanup

Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>

* Use builtin scanner function for checking whitespace in fallback method (its faster)

Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>
2021-05-24 15:28:52 -07:00
Wesley Wigham 2203228b62 Ensure static index signatures have an errorNode available (#44129)
* Ensure static index signatures have an errorNode available

* Lookup static index signature declarations in the right symbol table, stop checking prototype props
2021-05-24 14:30:59 -07:00
Wesley Wigham f414d13679 Dont allow generic narrowing when contextually typed by a binding pattern (#44081) 2021-05-13 16:51:52 -07:00
Wesley Wigham f7a97b7759 Cache accessibe symbol chains and serialized type parameter name generation (#43973)
* Cache accessibe symbol chains, type parameter name generation

* Move signature declaration helper length approximation to start of function

* Add node result caching internal to `typeToTypeNodeHelper`

* Suggestion from PR
2021-05-12 12:11:20 -07:00
Wesley Wigham a5607a4eab Dont allow namespace reexport symbols when looking up valid local names (#43969) 2021-05-06 12:03:48 -07:00
Wesley Wigham 456806b070 Allow filterType to consider union constraints of non-union types when determining never-ness (#43763)
* Allow filterType to consider union constraints of non-union types when determining never-ness

* Move impl to callback

* Baseline change in narrowing behavior into test, fix post-LKG build
2021-05-05 13:35:09 -07:00
Wesley Wigham b83148fe64 Unwrap substitutions on conditional check types before comparing them (#43888) 2021-05-05 13:33:45 -07:00
Wesley Wigham 84da19efc8 Add single-element fastpath to getSupertypeOrUnion (#43934) 2021-05-05 13:32:23 -07:00
Wesley Wigham 7748694d60 Relate non-augmenting subtypes without resorting to structural comparison (#43624)
* Relate non-augmenting array subtypes without resorting to structural comparison

* Fix lint

* Generalize performance enhancement

* Cache results, feed through via getNormalizedType to remove error intermediates

* Use newly freed up object flags to limit member setting, fix crash with those object flags

* Move flags because there is no TypeFlags.Reference 🤦
2021-04-27 22:52:12 -07:00
Wesley Wigham 5e4fcfbfb6 Add instantiation rules for reverse mapped types (#42449)
* Add instantiation rules for reverse mapped types

* Add smaller example of same issue
2021-04-27 15:01:46 -07:00