* Rename JS concepts
1. Assignment declaration -- an assignment that is treated like a
declaration. Previously called [JS] special (assignment|declaration),
among other things.
2. Expando -- a value that can be used as a target in assignment
declarations. Currently, a class, function or empty object literal.
Functions are allowed in Typescript, too. Previously called a JS
container, JS initializer or expando object.
3. JavaScript -> Javascript. This is annoying to type, and looks like
'Java Script' in a camelCase world.
Everything is a pure rename as far as I know. The only test change is
the API baselines, which reflect the rename from SymbolFlags.JSContainer
to SymbolFlags.Assignment.
* Remove TODO
* Rename Javascript->JS
Note that this introduces a variable name collision in a couple of
places, which I resolved like this:
```ts
const isInJavascript = isInJSFile(node);
```
* getTokenAtPosition: default includeJsDocComment to true
* Update API (#24966)
* Flip meaning of parameter
* Update API (#24966)
* Remove all `ignoreJsDocComment` uses (fixes#25162)
* Add refactor to convert named to default export and back
* Support ambient module
* Handle declaration kinds that can't be default-exported
* Update API (#24966)
* 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 "."
* 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
* 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
* Add initial tests
* Add types
* Half of parsing (builds but does not pass tests)
* Parsing done; types are uglier; doesn't crash but doesn't pass
* Bind callback tag
Builds but tests still don't pass
* Only bind param tags inside callback tags
* Fix binding switch to only handle param tags once
* Checking is 1/3 done or so.
Now I'm going to go rename some members to be more uniform. I hate
unnnecessary conditionals.
* Rename typeExpression to type (for some jsdoc)
(maybe I'll rename more later)
* Rename the rest of typeExpressions
Turns out there is a constraint in services such that they all need to
be named the same.
* Few more checker changes
* Revert "Rename the rest of typeExpressions"
This reverts commit f41a96b24d.
* Revert "Rename typeExpression to type (for some jsdoc)"
This reverts commit 7d2233a00e.
* Finish undoing typeExpression rename
* Rename and improve getTypeParametersForAliasSymbol
Plus some other small fixes
* Core checking works, but is flabbergastingly messy
I'm serious.
* Callback return types work now
* Fix crash in services
* Make github diff smaller
* Try to make github diff even smaller
* Fix rename for callback tag
* Fix nav bar for callback tag
Also clean up some now-redundant code there to find the name of typedefs.
* Handle ooorder callback tags
Also get rid of redundant typedef name code *in the binder*. It's
everywhere!
* Add ooorder callback tag test
* Parse comments for typedef/callback+display param comments
* Always export callbacks
This requires almost no new code since it is basically the same as
typedefs
* Update baselines
* Fix support for nested namespaced callbacks
And add test
* Callbacks support type parameters
1. Haven't run it with all tests
2. Haven't tested typedef tags yet
3. Still allows shared symbols when on function or class declarations.
* Template tags are now bound correctly
* Test oorder template tags
It works.
* Parser cleanup
* Cleanup types and utilities
As much as possible, and not as much as I would like.
* Handle callback more often in services
* Cleanup of binder and checker
* More checker cleanup
* Remove TODOs and one more cleanup
* Support parameter-less callback tags
* Remove extra bind call on template type parameters
* Bind template tag containers
Doesn't quite work with typedefs, but that's because it's now stricter,
without the typedef fixes. I'm going to merge with jsdoc/callback and
see how it goes.
* Fix fourslash failures
* Stop pre-binding js type aliases
Next up, stop pre-binding js type parameters
* Further cleanup of delayed js type alias binding
* Stop prebinding template tags too
This gets rid of prebinding entirely
* Remove TODO
* Fix lint
* Finish merge with use-jsdoc-aliases
* Update callback tag baselines
* Rename getTypeParametersForAliasSymbol
The real fix is *probably* to rename Type.aliasTypeArguments to
aliasTypeParameters, but I want to make sure and then put it in a
separate PR.
* Add 'move to new file' refactor
* Code review, and support commonjs
* Compute movedSymbols completely before using, and support `export import`
* Fix assertion error: sort empty change before non-empty change
* Remove extra newline
* Add allowTextChangesInNewFiles preference
* Add the new file to 'files' in tsconfig
* Avoid parameter initializer
* Update API baselines
* Use path relative to tsconfig.json
* Code review
* Fix error where node in tsconfig file was missing a source file
* add refactor of convert private field to getter and setter
* fix refactor
* stash
* refactor accessor generate
* revert merge union type
* refeactor and accept baseline
* add support of PropertyAssignment and StringLiteral
* add support for js file
* allow static modifier in js file
* replaceNode: Always use non-adjusted end
* Never adjust start position either
* Fix excess property checks, remove unnecessary arguments
* Make 'insertText' and 'newLineCharacter' private
* Use replaceNode in one more place now that it doesn't affect comments
* Update replaceNodeRange too
* Always ask for ChangeNodeOptions
* Apply 'no-unnecessary-initializer' lint rule
Forbids `let`/`const` statements to be initialized to `undefined`, since that's the initial value by default anyway.
The auto-fixer also happened to remove two unnecessary `as number` casts in `src/harness/parallel/worker.ts`.
For historical data: to run with `--fix`, I modified the line in `Jakefile.js` that declared the `cmd` for running TSLint.
* Moved worker.ts type assertions to parameters
* Convert 'installTypesForPackge' refactor to a suggestion
* Have checker collect a list of suggestion diagnostics instead of redoing work in calculateSuggestionDiagnostics
* Add comment
* Add diagnostic even with `--allowJs`
* Use getAllowSyntheticDefaultImports to access `--allowSyntheticDefaultImport` value
* Fix#21788: Handel missing imporotClause case
* Fix#21789: Add a defensive check to forgottenThisPropertyAccess code fix for non-identifier locations
* Do not suggest prefix with `this` if the name we are looking for is diffrent from the errorLocation
* Fix#21796: Handel case of unknown module
* Add check to capture more info for #21800
* Fix#21807: check for symbol before looking up its flags
* Fix#21812: Gracefully fail if the token is not `this`.
* Make ChangeTracker#newLineCharacter public, to avoid having to pass newLineCharacter around as a parameter
* Don't require newLineCharacter as input to ChangeTracker methods, and make it private again
* Remove unnecessary wrapper classes in ts.formatting.Rule
* RulesProvider -> immutable FormatContext
* Remove Rules class, just use a list of rules
* Remove Shared namespace, replace Shared.TokenRange with TokenRange
* Simplify TokenRange
* Separate Rule and RuleSpec
* Move FormattingRequestKind to formattingContext.ts
* Simplify references
* Fix lint
* Revert removal of trailing newlines
* Use NodeFlags to detect nodes in ambient contexts instead of climbing ancestors
* Set context flags on tokens
* Remove 'isDeclarationFile' parameter to 'initializeState' and move to 'parseSourceFileWorker'
* Changes based on code review
* Update API baselines
* Add utility function to check for strict option flags
- Correctelly check for noImplicitAny in checker
- Correctelly check for noImplicitAny in installTypesForPackage refactor
* Respond to code review comments
* Accept baselines
* Revert "Accept baselines"
This reverts commit cf4ef62830.
* Move type alias to core
1. Transform index signatures to TS index signatures.
2. Print object literals on a single line.
3. Only offer the refactor when it could add types. (There must not be a
type annotation already, and there must be a JSDoc that applies.)
If there are only declarations, use the new function as the initializer
for a destructuring declaration.
If there are declarations and writes, changes all of the `const`
declarations to `let` and add `| undefined` onto any explicit types.
Use destructuring assignment to accomplish both "initialization" and
writes.
I don't believe there is a case where there are both declarations and a
return (since the declarations wouldn't be available after the return).
UNDONE: this could probably be generalized to handle binding patterns
but,
for now, only identifiers are supported.
Fixes#18242Fixes#18855
Found while updating #18285 to latest master. Not sure what this fixes, but it was definitely incorrect - `node` must be a `Block` at this point, so this cast must have been intended for `node.parent`, which was checked against `TryStatement` right before it.
1) Replace range, rather than node, to leave trivia intact.
2) Only replace node in the innermost scope - otherwise insert as usual
and delete the original statement.
Old: Insert the same Node for every occurrence. The position was
repeatedly mutated during printing.
New: Thunk the Node so that a new one is constructed for every
occurrence.
Fixes#18857
Now that we're smarter about where we declare the extracted local, we
can ignore usage problems in the innermost script - it'll always have
access to the same symbols as the extracted expression.
...mostly by putting them closer to the extraction site.
They now also follow all leading comments in a file (unfortunately,
including the doc comment on the first declaration).
Bonus: Special case declaration lists - declare the new variable as part
of the list, rather than before it, in case it depends on an earlier
entry.
1) It assumed left-associativity and was, therefore, wrong for (e.g.)
exponentiation.
2) Arguably, if a user selects `a + |b + c|`, they want to extract `b +
c`, not `a + b + c`. Not being able to do so is surprising (and we may
eventually want to allow it), but so is having the rest of the
least-common subtree extracted.
Fixes#18268