Use originalFileName (fileName of input project reference file) to resolve module/typereferences/reference paths in it instead of output decl file path
* 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);
```
As `files` always contains declaration files of external libraries, lib files and declaration files from typeRoots, the previous condition evaluated to false for probably all projects out there.
This changes the condition to compare array length after filtering out all declaration files.
That avoids unnecessary work of path normalization in the common case where everything is ok.
Avoids using the TypeChecker when trying to reuse the Program structure.
This allows SourceFiles contained in the old Program to be updated using ts.updateSourceFile
Fixes: #26166
Project references need to be detached from the project when closing project
In SourceMapDecoder handle when the redirected file to project reference is set as the output of the project
Keep configured project alive if project it references has open ref
Fixes#26164
* importFixes: When one file redirects to another, consider both for global import specifiers
* Add test for #26044
* Avoid a symlinked package globally importing itself (fixes another case of #26044)
* Compare to node_modules with getCanonicalFileName
* navigateTo: Collect results from all referenced projects.
* Don't use project references, just source maps
* Move more code to session
* Test when implementation file is deleted
* Use tsserver tests instead of fourslash tests to ensure session is used
* Support find-all-references
* Restore fourslash tests
* Update emit baselines (added missing newline)
* Support rename
* @weswigham code review
* Don't open/close files
* Avoid growing `toDo` too eagerly
* @sheetalkamat code review
* Also get symlinked projects for originalLocation
* Update API (#24966)
* More @sheetalkamat code review
* Remove unnecessary test
* Update API (#24966)
* Adds related spans and error grouping for duplicate identifier errors
* Trim trailing whitespace
* Record related info in error baselines
* Make error more whimsical
* Multifaceted approach to performantly enabling fileExists outside of the synchronize step in the emit host
* make cache undefinable and handle correctly
* Remove unneeded cast
* Readd assert
* More useful failure messager
* Generate normal 1-part sourcemaps (at increased processing cost), since tools dislike sectional ones
* Add semicolon
* Accept sad baselines]
* Forward along sourcesContent if available
* Supress lint since the API actually calls for null here
* Fix concatenated sourcemap paths
* Accept bad baselines :(
* Add overloads
* Accept api update
* Fix lint
* Use more nodelike paths for import types when possible
* move functionality from services into compiler, fix with propert file/directory conflict handling
* mark suspect cast
* 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
* Type side of import types
* Value side of import types
* Accept library changes
* Refined implementation, more tests
* Allow resolutions to be performed late if the resolution still results in a file already in the build
* Add another test case
* Add some jsdoc usages
* Allow nodebuilder to use import types where appropriate
* Parse & check generic instantiations
* use import types in nodebuilder for typeof module symbols
* Wire up go to definition for import types
* Accept updated type/symbol baselines now that symbols are wired in
* PR feedback
* Fix changes from merge
* Walk back late import handling
* Remove unused diagnostic
* Remove unrelated changes
* Use recursive function over loop
* Emit type arguments
* undo unrelated change
* Test for and support import type nodes in bundled declaration emit
* Add compiler option to enable declaration sourcemaps
* Transparent goto definition for sourcemapped declaration files
* Post-rebase touchups
* Rename API methods
* Fix lints
* Fix typo in name XD
* Log sourcemap decode errors
* Share the cache more, but also invalidate it more
* Remove todo
* Enable mapping on go to implementation as well
* Allow fourslash to test declaration maps mroe easily
* more test
* Handle sourceRoot
* Add tests documenting current behavior with other sourcemapping flags
* Ignore inline options for declaration file maps, simplify dispatch in emitter
* Change program diagnostic
* Fix nit
* Use charCodeAt
* Rename internal methods + veriables
* Avoid filter
* span -> position
* Use character codes
* Dont parse our sourcemap names until we need to start using them
* zero-index parsed positions
* Handle sourceMappingURL comments, including base64 encoded ones
* Unittest b64 decoder, make mroe robust to handle unicode properly
* Fix lint
* declarationMaps -> declarationMap
* Even more feedback
* USE Mroe lenient combined regexp
* only match base64 characters
* Fix nit
The diagnostics reporting and expression resolution caching is quite intermingled at present.
Hence when we tried to get the declaration output without getting diagnostics, the resolution for functions return expression is cached but errors arent reported
Symbols arent marked as referenced. So at later time when trying to get the diagnostics since the expression resolution is cached, it doesnt even go through all checks
For now get diagnostics irrespective of declaration only output to avoid this issue.
Fixes#21518
* Integrate importStar and importDefault helpers
* Accept baselines
* Support dynamic imports, write helpers for umd module (and amd is possible) kinds
* Accept baselines
* Support AMD, use same helper initialization as is normal
* update typechecker to have errors on called imported namespaces and good error recovery with a quickfix
* Overhaul allowSyntheticDefaultExports to be safer
* Put the new behavior behind a flag
* Rename strictESM to ESMInterop
* ESMInterop -> ESModuleInterop, make default for tsc --init
* Rename ESMInterop -> ESModuleInterop in module.ts, add emit test (since fourslash doesnt do that)
* Remove erroneous semicolons from helper
* Reword diagnostic
* Change style
* Edit followup diagnostic
* Add secondary quickfix for call sites, tests forthcoming
* Add synth default to namespace import type, enhance quickfix
* Pair of spare tests for good measure
* Fix typos in diagnostic message
* Improve comment clarity
* Actually accept the updated changes to the esmodule interop description
* ESModule -> esModule
* Use find and not forEach
* Use guard
* Rely on implicit falsiness of Result.False
* These should have been emit flags
Timestamps look like Gulp's, with grey times inside white brackets.
Files have cyan filenames, yellow line and column numbers, and grey TS{####} errors. I wonder if those are actually useful for folks using the --pretty CLI: are they used for anything outside Visual Studio... Can we just get rid of them?
Re-uses compiler/program's color logic in compiler/watch. The relevant variables are now exported and marked `@internal`. Is there a preferred way of re-using this code in both those files?
This allows reporting of semantic errors as well. Semantic errors are
likely to outnumber syntactic errors, so it's valuable not to block
semantic errors on a few syntactic errors.
* 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
This marks files reused correctly as from external library resulting in not using them for files to be emitted and computed for output structure
Fixes#19327
* Actually support baselining pretty in the harness
* Test case from 18216
* Use host newline in formatDiagnosticsWithColorAndContext
* Merge statements
* For duplicate source files of the same package, make one redirect to the other
* Add reuseProgramStructure tests
* Copy `sourceFileToPackageId` and `isSourceFileTargetOfRedirect` only if we completely reuse old structure
* Use fallthrough instead of early exit from loop
* Use a set to efficiently detect duplicate package names
* Move map setting outside of createRedirectSourceFile
* Correctly handle seenPackageNames set
* sourceFileToPackageId -> sourceFileToPackageName
* Renames
* Respond to PR comments
* Fix bug where `oldSourceFile !== newSourceFile` because oldSourceFile was a redirect
* Clean up redirectInfo
* Respond to PR comments
* Add 'name' property to Identifier
* Rename to unescapedText
* Rename 'id.text' to 'id.escapedText'
* Rename 'id.unescapedText' to 'id.text'
* Make escapeIdentifier and unescapeIdentifier do nothing
* Created a branded type for escaped strings
Then flowed it throughout the compiler, finding and fixing a handful of
bugs relating to underscore-prefixed identifiers in the process.
Includes a test for two cases noticed - diagnostics from conflicting
symbols from export *'s, and enum with underscore prefixed member emit.
* Correctly double underscores WRT mapped types
* Add fourslash tests for other fixed issues
* use function call over cast
* Update forEachEntry type accuracy
* Just use escaped names for ActiveLabel
* Remove casts from getPropertyNameForPropertyNameNode
* This pattern has occurred a few times, could use a helper function.
* Remove duplicated helper
* Remove unneeded check, use helper
* Identifiers list is no longer escaped strings
* Extract repeated string-getting code into helper
* Rename type and associated functions
* Make getName() return UnderscoreEscapedString, add getUnescapedName()
* Add list of internal symbol names to escaped string type to cut back on casting
* Remove outdated comments
* Reassign interned values to nodes, just in case
* Swap to string enum
* Add deprecated aliases to escapeIdentifier and unescapeIdentifier
* Add temp var
* Remove unsafe casts
* Rename escaped string type as per @sandersn's suggestion, fix string enum usages
* Reorganize double underscore tests
* Remove jfreeman from TODO
* Remove unneeded parenthesis
Make Program.getMissingFilePaths required
Assume getMissingFilePaths always returns a defined value
Make getMissingFilePaths internal
Replace nullable-bool with enum
Update type to reflect possibility of undefined
Use deepEqual to simplify tests
Make condition const
Don't bother cleaning up map before freeing it
Switch from foreach to for-of to simplify debugging
Use a Map, rather than a FileMap, to track open FileWatchers
Fix compilation errors
Introduce and consume arrayToSet
Fix lint warnings about misplaced braces
Delete incorrect comment
Delete from map during iteration
Eliminate unnecessary type annotations
1. Expose missing files from the `Program`.
2. In `tsc --watch` and `tsserver`, add file watchers to missing files.
3. When missing files are created, schedule compilation (tsc) or refresh
the containing projects (tsserver).
* importFixes: Support missing "React" at a JSXOpeningElement
* Fix nextLineRule linting
* Rename to resolveJsxNamespaceAtLocation
* Expose getJsxNamespace and resolveNameAtLocation separately