Commit Graph
1842 Commits
Author SHA1 Message Date
Daniel Rosenwasser 79286ebd0c forEach -> forEachChildIn 2022-08-09 20:57:00 +00:00
Daniel Rosenwasser 059572ab36 Try using an unconditional no-op function. 2022-08-09 20:41:58 +00:00
Daniel Rosenwasser 85a0937352 Try pushing undefined to create a packed Array. 2022-08-09 18:49:55 +00:00
Daniel Rosenwasser f8e1c2afaa Co-locate each assignment into forEachChildTable. 2022-08-08 22:47:25 +00:00
Daniel Rosenwasser e42cfaf14c Let's see if 'new' changes anything. 2022-08-08 21:34:07 +00:00
Daniel Rosenwasser f671ea7574 Swap forEachChild to use an array of functions instead of a switch statement. 2022-08-08 21:12:35 +00: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 HejlsbergandDaniel Rosenwasser 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
Jake Bailey 7d60dc1f5d Revert "feat(47595): allow using private fields in type queries" (#48959) 2022-05-04 16:50:30 -07:00
Jake Bailey f579f3307e Revert "Don't treat a colon in a conditional expression branch as part of an arrow function" (#48940) 2022-05-04 15:01:05 -07:00
Daniel Rosenwasser 5f9c9a6ccf Start Node ESM stable version at Node16 (#48879)
* Remove Node12, add Node16.

* Accepted baselines.

* Refactor checking for top-level await, give a better error message in CJS files.

* Accepted baselines.

* Stop erroring on JSON module imports in node ESM since they're no longer experimental.

* Accepted baselines.

* More refactoring, do the same checks for for-await loops.

* Accepted baselines.

* Adjust phrasing to permit for-await on CJS error.

* Accepted baselines.

* Accepted baselines.

* Fix lints.
2022-05-03 16:29:40 -07:00
Nathan Shively-Sanders 2a78b225d0 Stop tag after @callback from crashing (#48860)
By copying the kludge in @typedef. @callback's order is simpler, so the
kludge is simpler. However, it's wrong here, and in @typedef. Parsing
tag comments is normally supposed to happen at the end of a tag, but in
@callback and @typedef happens *before* parsing the nested
@param/@property tags.

I still need to figure out what a real fix is -- but for the beta,
copying the existing crash-avoidance kludge from @typedef is best
anyway. I added a test case for typedefs for future use as well.
2022-04-27 11:21:10 -07:00
Jake Bailey d3943fc86f Disallow line break between entity name and type arguments in typeof expression (#48755) 2022-04-18 16:18:31 -07:00
Anders Hejlsberg a027cfa8ac More permissive parsing of instantiation expressions (#48659)
* More permissive parsing of expressions with type arguments

* Add test
2022-04-13 09:16:43 -04:00
Sheetal Nandi 988fa85f88 Handle declaration file names consistently (#48647) 2022-04-12 11:43:57 -07:00
Ron Buckton 7da80d79e2 Add 'extends' clause to 'infer' type (#48112)
* Add 'extends' clause to 'infer' type

* Revise parse for infer..extends, improve parenthesizer

* More aggressive parens to match existing DT tests

* tests 'infer' constraint using outer type parameter

* Adds a test showing 'infer' cannot reference other 'infer' in same 'extends'

* Emit extends clause for synthetic infer typesduring declaration emit
2022-04-05 12:35:28 -07:00
Jake Bailey 276719753e Allow arrow function parameter parsing to bail out during speculation, redo (#48493)
* Allow arrow function parameter parsing to bail out during speculation, redo

* Add correct baselines

* Allow await/yield keywords for more graceful error reporting

* Add test for other parser issue

* Address some PR feedback

* Add extra comment

* Add async variants
2022-04-04 16:57:26 -07:00
Anders Hejlsberg 6cb58d382f Optional variance annotations (#48240)
* Simplify getVariancesWorker and associated logic

* Accept new API baselines

* Add 'in' and 'out' modififers / add modifiers to type parameters

* Check variance annotations

* Update test runner

* Accept new API baselines

* Allow variance annotations only on certain type parameters

* Add deprecated implementation of createTypeParameterDeclaration

* Accept new API baselines

* Report variance markers as 'sub-XXX' and 'super-XXX'

* Add tests

* Accept new baselines
2022-03-22 11:31:08 -07:00
Jesse TrinityandNathan Shively-Sanders 111ca92646 Fix parser regression for bad related diagnostic on missing matching brackets (#44158)
* Revert "Revert #43460 and #40884 (#44175)"

This reverts commit 5770434891.

* fix missing opening brace match error

* refactor parseExpectedMatchingBrackets

* use getNodePos

* accept baselines

* delete mistakenly added files

* Revert getNodePos addition

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-03-15 17:29:41 -07: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
Nathan Shively-Sanders 918f0ef404 Rename SyntaxKind.JSDocComment -> JSDoc (#44416)
* Rename SyntaxKind.JSDocComment -> JSDoc

Early on, I made the mistake of using the syntax kind JSDocComment for
the type JSDoc. This arose because
I hadn't decided on the terminology of "jsdoc" for the C-style comment
that is attached to a declaration. "comment"
for the text that follows a tag. By the time I settled on those terms
consistently, a version had already shipped with `interface JSDoc`
having `SyntaxKind.JSDocComment`.

However, there is now a `type JSDocComment` that represents the possible
contents of the comment text (strings and various kinds of `@link`), so
it's doubly confusing that this type has a union of four kinds instead
of SyntaxKind.JSDocComment.

Although this is a public API break, I don't think it's hard to recover
from, and the JSDoc API has accessors for individual tag types, so I
suspect few people refer directly to SyntaxKind.JSDocComment.

* Add deprecate JSDocComment alias to JSDoc

For backward compatibility

* Make JSDoc an alias of JSDocComment

Improves output of JSDocParsing tests without having to make its code
smarter.

* update API baselines
2022-03-09 09:51:29 -08:00
Wesley Wigham ea0db9e031 Add import assertions to type only imports and import types to force the resolution mode of the specifier (#47807)
* Add import assertions for type-only imports and import types to change resolver modes

* By popular request, only allow mode assertions on top-level type only imports

* Add specifier options parameter to specifier generation
2022-03-02 08:54:10 -08:00
Jake Bailey e4fe50cca4 Fix incorrect parser error assumption in semicolon handling leading to incremental parser brokenness (#48067) 2022-02-28 17:05:32 -08:00
Jake Bailey 2dede207ae Don't treat a colon in a conditional expression branch as part of an arrow function (#47550) 2022-02-25 13:08:18 -08:00
Anders Hejlsberg 5afbfbcbd0 Instantiation expressions (#47607)
* Permit type arguments in references to generic functions

* Accept new baselines

* Delete pointless fourslash test

* Fix lint issue

* Finalize implementation

* Add tests

* Accept new baselines

* Properly handle instantiation of instantiation expression types

* Accept new API baselines

* Fix lint error

* Add more tests

* Properly handle unions/intersections of generic types

* Add more tests

* More permissive parsing of type arguments in member expressions

* Update tests

* Accept new baselines
2022-02-16 13:27:16 -08:00
Oleksandr T b9a06e515f fix(47261): allow linkcode/linkplain tags in see tag (#47403) 2022-02-15 17:20:51 -08:00
Oleksandr T 063eaa70e6 feat(47595): allow using private fields in type queries (#47696) 2022-02-15 15:48:10 -08:00
Wesley WighamandNathan Shively-Sanders 67172e41c2 Triple-slash reference type directives can override the import mode used for their resolution (#47732)
* Triple-slash reference type directives can override the import mode used for their resolution

They now use the file's default mode by default, rather than always using commonjs. The new arguments to the
reference directive look like:

```ts
///<reference types="pkg" resolution-mode="require" />
```

or

```ts
///<reference types="pkg" resolution-mode="import" />
```

* Omit redundant import modes in emitter

* Add test for #47806

* Add server test for triple-slash reference mode overrides

* Move FileReference mode into helper

* Update tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride3.ts

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-02-15 13:53:11 -08:00
Oleksandr T 1b1530ae52 fix(47713): allow JSDoc tags on CaseClause nodes (#47741) 2022-02-15 13:27:54 -08:00
Oleksandr T 20b5523830 feat(42684): allow deprecated JSDoc tag to be used on aliased nodes (#47293) 2022-01-25 15:49:33 -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
mickey-stringerandmickey-stringer 9e2b7ad0d8 fix(47492): more detailed parseTryStatement error message (#47504)
* more detailed parseTryStatement error message

* move custom error to diagnosticMessages.json

* update error code

Co-authored-by: mickey-stringer <fcstring31@yahoo.com>
2022-01-19 15:32:47 -08:00
Hiroshi Ogawa 8974fead2d fix(47062): support generic arrow function with default type parameter in tsx (#47112)
* fix(47062): support generic arrow function with default type parameter in tsx

* test: update test "completionListIsGlobalCompletion"
2021-12-14 09:02:36 -08:00
Jake Bailey 4013271cd8 Unwrap parens when checking for JSDocFunctionType in conditional expression (#46962) 2021-12-06 16:44:37 -08:00
Jake Bailey cdf12f91c7 Fix parsing of parenthesized functions in conditional expressions (#46960) 2021-11-30 12:57:37 -08:00
Oleksandr T ce676d0963 fix(46433): forbid using keywords as parameter names (#46459) 2021-10-22 09:58:01 -07:00