1870 Commits

Author SHA1 Message Date
Ron Buckton
5b18979697
Implement the Stage 3 Decorators Proposal (#50820) 2023-01-19 17:54:12 -05:00
Jake Bailey
22b362ceac
Enable strictFunctionTypes (#49929) 2023-01-17 17:20:51 -08:00
Oleksandr T
9c9d4b029d
feat(51086): satisfies support in JSDoc (#51753) 2023-01-17 10:22:22 -08:00
Ron Buckton
9cdba994ac
Remove some properties from Identifier (#52170) 2023-01-12 17:20:12 -05:00
Wesley Wigham
89e928e8b4
Add --allowArbitraryExtensions, a flag for allowing arbitrary extensions on import paths (#51435) 2023-01-09 17:12:42 -08:00
Ron Buckton
90fb764a0f
Fix private name generation and missing emit for auto-accessors (#52132) 2023-01-06 21:08:51 -05:00
Oleksandr T
44152bc22e
fix(29648): Error message related to JSDoc for non-JSDoc syntax error (#50793)
* fix(29648): improve diagnostics of non-JSDoc syntax errors

* fix lint errors

* update tests

* change diagnostic type suggestion. fix QF for jsdoc nullable type

* move error handling from the parser to the checker

* change diagnostic message. remove speculative parsing

* update baseline
2022-12-29 16:50:57 -08:00
Anders Hejlsberg
fede84e85b
const modifier on type parameters (#51865)
* `const` modifier on type parameters + revised contextual type logic

* Accept new baselines

* Fix modifier checking

* Add tests

* Cache isConstTypeVariable check

* Revert "Cache isConstTypeVariable check"

This reverts commit f8fd1fd29f7975fcc3aeac8675c2cb107da33065.

* Fewer isConstTypeParameterContext checks

* Pay attention to cached `undefined` contextual type

* Allow `const` modifier in more places + properly print back

* Also permit `const` in method signature type parameters

* Fix parsing of `const` modifier in array expression type parameters

* Accept new baselines

* Remove unused properties from NodeLinks

* Rename `permitInvalidConstAsModifier` to `permitConstAsModifier`
2022-12-16 13:47:10 -08:00
Oleksandr T
20f3060da5
Add JSDocOverloadTag to ForEachChildTable (#51907)
* add JSDocOverloadTag to ForEachChildTable

* fix tests

* change imports order
2022-12-16 08:41:32 -08:00
Tomasz Lenarcik
e4816ed44c
JSDoc overload tag (#51234)
* Add support for JSDocOverloadTag

* Use overload tag to determine function type

* Update baselines

* Add new tests along with baselines

* Add tests for all @overload tags in one comment

* Add tests for find-all-ref and rename operations

* Add tests for alternative uses of @overload tag

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-12-13 15:10:40 -08:00
Ron Buckton
6d41964fd0
Reduce polymorphism resulting from unstable Node shapes (#51682)
* Move .symbol to Declaration

* simplify some factories

* Move localSymbol to Declaration

* Ensure JSDocContainer types are properly initialized

* Move contextualType from Node to NodeLinks

* Move 'locals' and 'nextContainer' out of Node

* Move 'flowNode' out of 'Node'

* Pre-define endFlowNode/returnFlowNode

* Pre-define some SourceFile properties and a more stable cloneNode

* Don't add excess properties to type nodes in typeToTypeNode

* Refactor wrapSymbolTrackerToReportForContext to improve perf
2022-12-13 15:11:10 -05:00
Oleksandr T
355991c806
feat(49323): Render JSDoc @throws {type} as a link (#49891)
* feat(49323): add support throws jsdoc tag

* change "name" to "typeExpression". parse "exception" as a synonym for "throws"

* include typeExpression from the throws tag in the quick info

* add JSDocThrowsTag to ForEachChildNodes
2022-12-12 14:44:38 -08:00
Jake Bailey
00dc0b6674
Flip imports to case insensitive sorting (#51579) 2022-11-17 15:35:28 -08:00
Jake Bailey
2d2a4343b8
Reformat imports to be one identifier per line (#51565) 2022-11-17 13:42:18 -08:00
Sheetal Nandi
c5aea89230
Add alias ResolutionMode for ModuleKind.ESNext | ModuleKind.CommonJs | undefined (#51482)
* Add alias ResolutionMode for ModuleKind.ESNext | ModuleKind.CommonJs | undefined

* ResolutionMode | undefined = ResolutionMode

* More
2022-11-10 16:47:46 -08:00
Jake Bailey
9f64a3a58c
Remove ts.{Map,Set,ESMap,Iterator} and associated types (#51439) 2022-11-09 15:06:31 -08:00
Jake Bailey
db440d8468 Directly import namespaces for improved esbuild output
I should report this upstream, if I can manage to minimize this.
2022-11-07 13:36:08 -08:00
Jake Bailey
c65142244c Add dts bundling
This adds a "small" d.ts bundler script. This script is very basic,
using Node printing to produce its output. Generally speaking, this is
inadvisable as it completely disregards name shadowing, globals, etc.
However, in our case, we don't care about the globals, and we can opt to
restructure our codebase in order to avoid conflict, which we largely
had to do anyway when we were namespaces and everything was in scope.
2022-11-07 13:35:48 -08:00
Jake Bailey
d12116d8da Fix all internal JSDoc comments
If these are regular comments, then they won't appear in our d.ts files.
But, now we are relying on an external d.ts bundler to produce our final
merged, so they need to be present in the "input" d.ts files, meaning
they have to be JSDoc comments.

These comments only work today because all of our builds load their TS
files from scratch, so they see the actual source files and their
non-JSDoc comments.

The comments also need to be attached to a declaration, not floating,
otherwise they won't be used by api-extractor, so move them if needed.
2022-11-07 13:34:44 -08:00
Jake Bailey
07758c08ab Generated module conversion step - inlineImports
This step converts as many explicit accesses as possible in favor of direct imports from the modules in which things were declared. This restores the code (as much as possible) back to how it looked originally before the explicitify step, e.g. instead of "ts.Node" and "ts.Symbol", we have just "Node" and "Symbol".
2022-11-07 13:33:07 -08:00
Jake Bailey
b6c0538826 Generated module conversion step - stripNamespaces
This step converts each file into an exported module by hoisting the namespace bodies into the global scope and transferring internal markers down onto declarations as needed.

The namespaces are reconstructed as "barrel"-style modules, which are identical to the old namespace objects in structure. These reconstructed namespaces are then imported in the newly module-ified files, making existing expressions like "ts." valid.
2022-11-07 13:32:03 -08:00
Jake Bailey
9a0b85ce2a Generated module conversion step - explicitify
This step makes all implicit namespace accesses explicit, e.g. "Node" turns into "ts.Node".
2022-11-07 13:29:05 -08:00
Jake Bailey
94724a8c2e Generated module conversion step - unindent
This step makes further commits look clearer by unindenting all of the top level namespaces preemptively.
2022-11-07 13:28:13 -08:00
Jake Bailey
d0f0e35c88
Remove old tslint comments (#51220) 2022-10-18 17:30:42 -07:00
Daniel Rosenwasser
0d0a793714
Allow Unicode extended escapes in ES5 and earlier (#50918)
* Remove language version check for extended escapes.

* Accepted baselines.

* Record whether nodes have extended Unicode escapes. Replace them in the es2015 transform.

* Accepted baselines.

* Move file to better-reflect generality of tests.

* Added tests for variables at the top level.

* Accepted baselines.

* Added test for extended astral character.

* Accepted baseline.

* Enable sourcemaps in tests.

* Accepted baselines.

* Call `setOriginalNode` on identifiers with extended escapes.
2022-09-30 01:22:01 -07:00
Daniel Rosenwasser
d90795e799
Improve escape sequence handling in private names (#50856)
* Add tests for identifiers and private identifiers with escape sequences.

* Accepted baselines.

* Store the tokenValue instead of tokenText on PrivateIdentifiers, since the latter can contain escapes and lead to semantic discrepancies.

* Accepted baselines.

* Check for leading escape sequences in PrivateIdentifiers.

* Accepted baselines.

* Fix lints.
2022-09-20 15:00:39 -07:00
Jake Bailey
16156b1baf
Add rules from eslint's recommended set that triggered good lints (#50422) 2022-09-19 16:20:55 -07:00
Oleksandr T
08b91f6b82
fix(50717): tsc crashes when it sees a JSDoc tag inside an @override annotation (#50724) 2022-09-13 12:51:17 -07:00
Ron Buckton
a4cabe725b
Support for auto-accessor fields from the Stage 3 Decorators proposal (#49705)
* Support for auto-accessor fields

* Add tests, ensure accessors are initialized in ctor

* classFields cleanup and PR feedback
2022-09-12 15:12:11 -04:00
Jake Bailey
226dd0b7bf
Fix typechecking related lints that changed post 4.8, update LKG to 4.8.2 (#50472) 2022-08-26 11:41:45 -07:00
Oleksandr T
164dddc48e
feat(7481): Operator to ensure an expression is contextually typed by, and satisfies, some type (#46827)
* feat(7481): add explicit type compatibility check with 'satisfies' expression

* Add failing test for lack of intersectioned contextual type

* Implement the behavior

* Add test corresponding to the 'if'

* Add test based on defined scenarios

* remove isExpression in favor of using type casting

* move tests from compiler to conformance folder

* update baseline

* add missing contextFlags argument

* use asserted type

* accept baseline

Co-authored-by: Ryan Cavanaugh <ryanca@microsoft.com>
2022-08-26 10:05:52 -07:00
Daniel Rosenwasser
4605d89064
Use a mapped type to enforce type-safety on forEachChild. (#50409) 2022-08-22 17:30:44 -07:00
Daniel Rosenwasser
76357ba802
Swap forEachChild to use a table of functions instead of a switch statement. (#50225)
* Swap `forEachChild` to use an array of functions instead of a `switch` statement.

* Let's see if 'new' changes anything.

* Co-locate each assignment into `forEachChildTable`.

* Try `push`ing undefined to create a packed Array.

* Try using an unconditional no-op function.

* `forEach` -> `forEachChildIn`

* Remove the optional chain if we are pre-filling with no-ops.

* Grab function directly to avoid possible `.call` overhead from downlevel emit.

* Swap to object literal.

* Lints and formatting.
2022-08-21 17:48:45 -07:00
Ron Buckton
284837d66b
Fixes for decorators property deprecations (#50343)
* Change type of deprecated 'decorators' property

* fix 'Invalid Arguments' error for create/update constructor in factory

* Update deprecation comments

* Make 'decorators' optional and 'undefined'

* Rename '_decorators' to 'illegalDecorators'

* Update baselines
2022-08-19 14:27:26 -04:00
Sheetal Nandi
394f51aeed
Fix implied formats, file watching, new source file creating during edits (#50098)
* Add test where module resolution cache is not local and hence doesnt report errors in watch mode

* Ensure module resolution cache is passed through in watch mode

* Remove unnecessary setting of impliedFormat which should anyways be done as part of create source file

* Add test for packge.json changing and modifying implied format

* Distinguish between package.json watch and affecting file location watch

* Pass in failed lookup and affected file locations for source file's implied format
Also stop creating options if we already have them

* Add diagnostic for explaining file's implied format if based on package.json

* Watch implied format dependencies for modules and schedule update on change

* For program if implied node format doesnt match create new source file. Handle implied node format in document registry
Fixes #50086

* Modify tests to show package.json being watched irrespective of folder its in

* Check file path if it can be watched before watching package.json file

* Because we are watching package.json files and failed lookups its safe to invalidate package json entries instead of clearing them out everytime program is created

* Remove todos

* Fix the incorrect merge

* Pickup PackageJsonInfo renames from #50088

* Rename
2022-08-01 12:41:37 -07:00
Jake Bailey
3afe2d654e
Resolve parsingContextErrors TODO (#50011)
* Add a test with broken code

* Resolve TODO
2022-07-26 08:59:06 -07:00
Ron Buckton
12dbdf03b1
Parse parameter decorators outside of Await context when appropriate (#50040) 2022-07-25 17:17:27 -04:00
Oleksandr T
f6ac10958f
fix(49704): Code folding not working in file with simple syntax error (#49743)
* fix(49704): parse type arguments in super call expression

* omit duplicate errors
2022-07-19 16:26:56 -07:00
Oleksandr T
e2e3c1285f
fix(49544): allow comma token after accessors (#49545) 2022-07-06 08:54:54 -07:00
Andrew Branch
2bc91a6b46
Fix parser TODO (#49679) 2022-06-27 09:05:41 -07:00
Jake Bailey
569cdf1b07
Disallow expression with type parameters as left side of property access (#49464) 2022-06-24 15:54:21 -07:00
Jake Bailey
d7e58c8ea9
Fix arrow expressions in conditional expressions, take N+1 (#49531) 2022-06-17 16:34:27 -07:00
Anders Hejlsberg
18ac37221b
Properly re-scan > token in type argument list determination logic (#49560)
* Properly re-scan '>' token in type argument list determination logic

* Add regression test
2022-06-15 12:06:08 -07:00
Anders Hejlsberg
e6808c4290
Instantiation expression can be followed by line break or binary operator (#49353)
* Allow instantiation expression to be followed by let or interface on new line

* Add tests

* Update src/compiler/parser.ts

* Instantiation expressions followed by line breaks or binary operators

* Add more tests

* Accept new baselines

* Fix lint error

* Update fourslash test

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2022-06-10 10:26:42 -07:00
Ron Buckton
1e65b330a7
Merge 'decorators' into 'modifiers' on various nodes (#49089)
* Merge 'decorators' into 'modifiers' on various Nodes

* Drop RESERVED argument in favor of removing parameter

* Ignore grammar error nodes when asserting invariants

* Revert 'illegalX' property renames

* PR Feedback
2022-06-09 17:24:02 -07:00
Oleksandr T
2cb8ee27f0
fix(48653): throw an error on an invalid optional chain from new expression (#48656) 2022-06-02 14:21:36 -07:00
Oleksandr T
c300fea325
fix(7410): allow using JSXElement as JSXAttributeValue (#47994) 2022-05-11 14:47:35 -07:00
David Souther
e9d39bd95f Remove spurious lookAhead, as this fn is already in a lookAhead 2022-05-09 10:53:58 -07:00
David Souther
3dd9ef43ce fix(44466): Fixes parsing contextual keyword casts as arrow functions 2022-05-09 10:22:22 -07:00
Jake Bailey
8d0393d227
Fix missing parsingContext restore at return in parseDelimitedList (#48999) 2022-05-06 13:36:27 -07:00