* Add test case to verify directory casing preservation when watching
* Fix unicode file name handling when watching failed lookup locations
* Add special file name lower conversion routine and use that instead of toLowerCase
Fixes#31819 and #35559
* Remove unicode from code
* Replace toLocaleLowerCase on filenames with ts.toFileNameLowerCase
* Make the intent of using toFileNameLowerCase more clear and why we make the restriction on turkish I with dot on top of it
* Update baselines for newly added tests in master
* Refactor the test
* Add tests for syntax errors in tsconfig not being reported
* Report config file parsing diagnostics correctly
Fixes#36515
* Fix errors in existing tests for unintended tsconfig parse errors
* Fix lint
* Handle when files get checked in different orders
* Fix interface extends clause
* Fix import= something type only from a module
* Revert apparently unnecessary addition
* Revert "Revert apparently unnecessary addition"
This reverts commit 7444b0b72e.
* Disallow `import = a.b.c` on anything with type-only imports
* Safety first
* Add test for TS Server single-file open
* Add big comment
* Extract error reporting function for import aliases
* Delete blank line
* Un-export, comment, and colocate some utils
* Combine 3 type-only marking function calls into one
* Add more export default tests
* WIP
* Test no longer crashes, but emit trampoline is incomplete and skips pipeline phases
* Fix lints, use non-generator trampoline in emit (still skips pipeline)
* Final version with emitBinaryExprssion work stack that is only used if possible
* Fix lints
* retarget to es2015 for testing
* Use bespoke state machine trampolines in binder and checker
* Remove now extraneous code in parser
* Adjust fixupParentReferences to use a depth first preorder traversal rather than breadth first
* Reintroduce incremental fast bail in fixupParentReferences
* Revert target to es5
* PR feedback
* Small edit for devops rebuild with updated definition
* Fix comment nits, add internally extraneous check back into transformer
* If script info is not attached to the project on which wild card is invoked, update it.
* Instead of getting default project before starting error list timer, get it at that time if no project is specified
Fixes#35794
* Fix the open File watch triggered setting
* Add test that demonstrates npm install watch behaviour some times
* Use watch invoked with `node_modules/.staging` as watch for refreshing complete node_modules, so that npm install is reflected correctly
Fixes#35966
Add a response property indicating how much of the elapsed time (from
`onMessage` to `doOutput`) was spent in `updateGraph` calls. If there's
no `updateGraph` call, the property is undefined, to save space (with
the downside that it's harder to tell whether a given telemetry event
could have had the property).
Fixes#34774
* Add type-only support for export declarations
* Use a synthetic type alias instead of binding type-only exports as a type alias
* Works for re-exports!
* isolatedModules works fine
* Diagnostic for type-only exporting a value
* Start isolated modules codefix
* Update for LKG control flow changes
* Type-only import clause parsing
* Type-only default import checking
* Type-only named imports
* Fix isolated modules error
* Filter namespaces down to type-only
* Fix class references
* Test nested namespaces
* Test circular type-only imports/exports
* Fix getTypeAtLocation for type-only import/export specifiers
* Fix type-only generic imports
* Update public APIs
* Remove unused WIP comment
* Type-only namespace imports
* Fix factory update calls
* Add grammar errors for JS usage and mixing default and named bindings
* Update updateExportDeclaration API baseline
* Fix grammar checking import clauses
* Enums, sort of
* Dedicated error for type-only enum
* Skip past type-only alias symbols in quick info
* Update error code in baseline
* WIP: convertToTypeOnlyExport
* isolatedModules codefix (single export declaration)
* isolatedModules code fix (all)
* Stop eliding non-type-only imports by default, add compiler flag
* Update to match updated diagnostic messages
* Update more baselines
* Update more tests
* Auto-import as type-only
* Add codefix for splitting type-only import with default and named bindings
* Add more services tests
* Add targeted error message for "export type T;" when T exists
* Add targeted error for "import type T = require(...)"
* Flip emit flag
* Add test for preserveUnusedImports option
* Fix flag flip on import =
* Make compiler option string-valued
* Fix merge conflicts
* Add --importsNotUsedAsValue=error
* Phrasing of messages.
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
* Baselining tsc --watch output
* Add noIndirectImports as a option to skip checking and generating .d.ts files for files indirectly importing affected file
Fixes#33329
* Rename option to assumeChangesOnlyAffectDirectDependencies
* Description change as per feedback
* Add support for Call Hierarchies in language server
* Use baselines for callHierarchy tests
* Clean up commented code
* Support multiple hierarchy items when an implementation can't be found
* Use optional chaining in a few places
* Use getFileAndProject
It was previously not populated correctly if preserveSymlinks with useSourceOfProjectReference was true,
in that case if module was resolved to symlink and we deduced it refers to source of project reference we want to set "resolvedFileName" correctly
otherwise it results in incorrect module not found errors.
* Add tests for noEmitOnError
* Do not write files directly from builder when noEmitOnError is true
Fixes#34823
* make linter happy
* Instead of generating output in memory, check errors before doing the emit in case of noEmitOnError
* Create different watch options in compiler options
* Thread through the new watch options
* Actually use the options passed through for watch strategy
* Support delay on updating child directory watches
* Make watchOptions separate from compilerOptions
* Support passing watch options from command line
* Handle displaying of watchOptions
* Add isInferredProject, isConfiguredProject and isExternalProject
* Skip refreshing configured project on change of config file if its not loaded
* Open a tree of projects when doing findAllRefs or rename operations
* Fix addToSeen project key
* Refactor combineProjectsOutputWorker
* if the definition is local, no need to load and look in other projects
* Add disableSearchSolution as option to disable looking for solution
* Rename the option to disableSolutionSearching
* Add isInferredProject, isConfiguredProject and isExternalProject
* Add test for rename on file with case change that fails
Test for #25460
* Dont store fileName on text storage
* Store root file names in the root file map to reflect their name
* Delay open file triggering watches
* Correct the name of source file as we query it (eg. it could be same source file returned in old program with different casing on case insensitive file name)
* More tests
* Refactoring
* Cache bind And check diagnostics and always get program diagnostics from the program
* Another test
* Try to report conflicting file error on file instead of global diagnostics
* Create better tests for module resolution diagnostics check
* Fix lint errors
* Move most harness globals into namespaces
* Remove forward declaration from `createMapShim` and move all `Map` declarations into one file
* A small pile of more changes to get the harness transforming
* Adds did you mean to the CLI args parser
* Adds test coverage for the did you mean on CLI args
* Adds did you mean to convertOptionsFromJson
* Ensure tsconfig compiler flags also get 'did you mean?'
* Use empty object for invalid package json contents instead of undefined
Fixes#34726
* Behave as if package json doesnt exist in case of invalid json in package json
When transforming a module declaration and block, parse tree nodes
contained in the module block have their parent pointers reset due to
`shouldEmitModuleDeclaration` calling into `isInstantiatedModule`, which
needs to set parent pointers to operate.
That causes a crash when later transforming any nodes within the module,
as retrieving their source file in `getSourceFileOfNode` (via
`getOrCreateEmitNode`) fails, due to their new synthesized parent nodes
not being in a source file.
This change avoids the issue by using the parse tree node in `ts.ts` to
decide whether a module declaration should be emitted (i.e. whether the
module contains values).
This means transformers cannot add values to modules that previously did
not contain any.
Fixes#34644.
The word multi-line and multiline are used interchangeably within the file. Multiline seems to be the most used spelling of the word across the TypeScript repository codebase so a few strings have been updated to keep consistency within a single file. Additionally, corrected a minor capitalization mistake.
Msbuild currently uses a combination of `--listFiles` and `--noEmit` to
obtain a list of files to be consumed by tsc. However, these two flags
don't suppress type checking, the results of which msbuild will never
consume. This new switch gives msbuild a faster way to obtain the file
list.
Note: like `--noEmit`, doesn't make sense in build mode.
* migrate nullish coalescing commit
* add more test case
* add branch type check test
* add more tests
* fix nullish precedence
* update public api
* add rescan question question token to fix regression
* update public api baseline
* Added tests that emit for nullish coalescing operator conforming with grammar restrictions when assertions are used.
* Fixed emit to hoist temporary variables (they previously went undeclared).
Added tests to ensure calls and property accesses are only called once.
* use not equal to null
* rename factory
* add grammar check
* fix more cases
* Fix handling of nullish coalescing oprator in expando objects.
* Fixed classifier to support ?? operator.
* update baseline
* accept baseline
* fix review
* update emitter and more testcase
* update control flow
* make linter happy
* update libs
* avoid unnecessary assert
* fix typooo
* Fixes for control-flow analysis
* Add support for Optional Chaining
* Add grammar error for invalid tagged template, more tests
* Prototype
* PR feedback
* Add errors for invalid assignments and a trailing '?.'
* Add additional signature help test, fix lint warnings
* Fix to insert text for completions
* Add initial control-flow analysis for optional chains
* PR Feedback and more tests
* Update to control flow
* Remove mangled smart quotes in comments
* Fix lint, PR feedback
* Updates to control flow
* Switch to FlowCondition for CFA of optional chains
* Fix ?. insertion for completions on type variables
* Accept API baseline change
* Clean up types
* improve control-flow debug output
* Revert Debug.formatControlFlowGraph helper
* Move package.json related utils to utilities
* Add failing test
* Make first test pass
* Don’t filter when there’s no package.json, fix scoped package imports
* Use type acquisition as a heuristic for whether a JS project is using node core
* Make same fix in getCompletionDetails
* Fix re-exporting
* Change JS node core module heuristic to same-file utilization
* Remove unused method
* Remove other unused method
* Remove unused triple-slash ref
* Update comment
* Refactor findAlias to forEachAlias to reduce iterations
* Really fix re-exporting
* Use getModuleSpecifier instead of custom hack
* Fix offering auto imports to paths within node modules
* Rename things and make comments better
* Add another reexport test
* Inline `symbolHasBeenSeen`
* Simplify forEachAlias to findAlias
* Add note that symbols is mutated
* Symbol order doesn’t matter here
* Style nits
* Add test with nested package.jsons
* Fix and add tests for export * re-exports
* Don’t fail when alias isn’t found
* Make some easy optimizations
* Clean up memoization when done
* Remove unnecessary semicolon
* Make getSymbolsFromOtherSourceFileExports pure
* Cache auto imports
* Revert "Cache auto imports"
This reverts commit 8ea4829587.
* Handle merged symbols through cache
* Be safer with symbol declarations, add logging
* Improve cache invalidation for imports and exports
* Check symbol presence first
* Only run cache invalidation logic if there’s something to clear
* Consolidate cache invalidation logic
* Fix reuseProgramStructure test
* Add more logging
* Only clear cache if symbols are different
* Refactor ambient module handling
* Start caching package.json stuff
* Support package.json searching in fourslash
* Move import suggestions cache to Project
* Start making more module specifier work available without having the importing file
* Going to backtrack some from here
* Get rid of dumb cache, fix node core modules stuff
* Start determining changes to a file have invalidated its own auto imports
* Move package.json related utils to utilities
* Add failing test
* Make first test pass
* Don’t filter when there’s no package.json, fix scoped package imports
* Use type acquisition as a heuristic for whether a JS project is using node core
* Make same fix in getCompletionDetails
* Fix re-exporting
* Change JS node core module heuristic to same-file utilization
* Remove unused method
* Remove other unused method
* Remove unused triple-slash ref
* Update comment
* Refactor findAlias to forEachAlias to reduce iterations
* Really fix re-exporting
* Use getModuleSpecifier instead of custom hack
* Fix offering auto imports to paths within node modules
* Rename things and make comments better
* Add another reexport test
* Inline `symbolHasBeenSeen`
* Simplify forEachAlias to findAlias
* Add note that symbols is mutated
* Symbol order doesn’t matter here
* Style nits
* Add test with nested package.jsons
* Fix and add tests for export * re-exports
* Don’t fail when alias isn’t found
* Make some easy optimizations
* Clean up memoization when done
* Remove unnecessary semicolon
* Make getSymbolsFromOtherSourceFileExports pure
* Cache auto imports
* Revert "Cache auto imports"
This reverts commit 8ea4829587.
* Handle merged symbols through cache
* Be safer with symbol declarations, add logging
* Improve cache invalidation for imports and exports
* Check symbol presence first
* Only run cache invalidation logic if there’s something to clear
* Consolidate cache invalidation logic
* Fix reuseProgramStructure test
* Add more logging
* Only clear cache if symbols are different
* Refactor ambient module handling
* Finish(?) sourceFileHasChangedOwnImportSuggestions
* Make package.json info model better
* Fix misplaced paren
* Use file structure cache for package.json detection when possible
* Revert unnecessary changes in moduleSpecifiers
* Revert more unnecessary changes
* Don’t watch package.jsons inside node_modules, fix tests
* Work around declaration emit bug
* Sync submodules?
* Delete unused type
* Add server cache tests
* Fix server fourslash editing
* Fix packageJsonInfo tests
* Add node core modules cache test and fix more fourslash
* Clean up symlink caching
* Improve logging
* Function name doesn’t make any sense anymore
* Move symlinks cache to host
* Fix markFileAsDirty from ScriptInfo
* Mark new Project members internal
* Use Path instead of fileName
* Rename AutoImportSuggestionsCache
* Improve WatchType description
* Remove entries() from packageJsonCache
* Fix path/fileName bug
* Also cache symlinks on Program for benefit of d.ts emit
* Let language service use Program’s symlink cache
* Allow allowJs and declaration to be used together
This intorduces a new symbol-based declaration emitter - currently this
is only used for JSON and JavaScript, as the output is likely worse than
what the other declaration emitter is capable of. In addition, it is
still incomplete - it does not yet support serializaing namespaces.
* Add tests for various import/export forms, add notes on export as namespace and fix export * from
* Tests & fixes for computed names
* Add test with current @enum tag behavior
* fix declaration emit for jsdoc @enum tags
* Small adjustments to base class serialization to fix bugs in it
* Guard against type/type parameter confusion when using typeParameterToName a bit
* Integrate feedback from PR
* Fix issue with export= declarations visibility calculation and type declaration emit that impacted all forms of declaration emit
* Only make one merged getCommonJsExportEquals symbol for a symbol
* Support preserving type reference directives in js declarations
* Skip declare mdoifiers for namespace members in ambient contexts
* FAKE ALIASES AND NAMESPACES EVERYWHERE
* Dont do namespace sugar when type members contain keyword names
* Fix json source file export modifier under new output
* Such clean nested aliasing, very wow
* Fix lint
* Add visibility errors, reuse type nodes where possible
* Suppoer having correctly named import types in bundled js declaration emit & adjust binding to allow namespaces with aliases to merge when the aliases look to be type-only
* Better support for module.exports = class expression
* Fix discovered crash bug
* Allow export assigned class expressions to be reachable symbols from external declarations
* Add missing semicolon
* Support @enum tag post-merge
* preserve comments on signatures and declarations where possible
* Basic support for js classy functions
* Add example we should do better with
* Prototype assignments make things a bit wonky, but the example from the PR seems OK
* Make a ton of changes to support the new way js classes are bound
* Remove some old comments, fix import and export default names
* Fix bug in object define handling and add tests for object define property declaration emit
* Fix organization nits from PR comments
* Preserve comments from jsdoc declarations on properties and js declaration type aliases
* Merge export declarations with identical specifiers
* Remove completed TODO comment
* Split lint
* Remove now-unused function
* PR feedback
* Add some project references tests, remove some checks from project refs codepaths that are now invalid
* Update project references tests again
* Merge and update project references tests
* Rename case
* Update test to include declaration output
* Remove yet another project refernces redirect extension check
* Update comment
* Add additional import ref to test
* Add shorthand prop to test
* Fix comment text
* Extract var to temp
* Simplify function and add whitespace
* Update project refs test to use incremental edit entry
* Stylistic refactors in the symbol serializer
* Another round of PR feedback, mostly style, small bugfix with constructors, and test showing bug in export assigned class expression name shadowing
* Use x instead of index
* Disallow property/accessor overrides
Unless the base property or accessor is abstract
* Disallow uninitialised property overrides
This causes quite a few test breaks. We'll probably want to revert many
of them by switching to the upcoming `declare x: number` syntax.
* Updates from design review + fix ancient bug
1. Don't error when overriding properties from interfaces.
2. Fix error when overriding methods with other things. This had no
tests so I assume that the code was always dead and never worked.
* Need to add a couple of errors and squash one
Will update after checking out other branch for a minute
* Everything works so far
Need to test properties initialised in constructor
* Check for constructor initialisation
* change error wording
* Improve error wording
* Add codefix to add missing 'declare'
* Always emit accessors in .d.ts files
* Allow 'declare' on any uninitialised property decl
* Undo code moves
* Let sleeping dogs lie
* Correctly set NodeFlags.Ambient
And simplify redundant parts of check.
* Remove more unneeded code
* Update baselines
* Update baselines
* Update baselines
* Ignore this-property assignments
* Fix base-in-interface check
* Do not error when base parent is interface
* Fix base interface check
* Add missed baselines
* Fix check
* Fix new errors in services
* Fix new errors in services
* Fix errors in testRunner
* Add flag and turn off errors when on
* Structure of new emit is correct, fake content
It is 'hi'.
* Basically right emit
* Fix one last unitialised property declaration
* Haha no I missed another one
* Fix whitespace back to CRLF
* Minor fix and code cleanup
* New test case
* Fix bug in isInitializedProperty
* Updates from design meeting.
1. Change flag name to useDefineForClassFields (and flip polarity).
2. Forbid ES3 + useDefineForClassFields (since there is no
defineProperty).
3. Forbid overriding an abstract property-with-initializer with an
accessor.
* Update baselines
* Object.defineProperty for methods too
Using code from Ron from his upcoming refactor of the factory functions.
* Update slow baselines
* Improve error message
* Update src/compiler/transformers/utilities.ts
Co-Authored-By: Andrew Branch <andrewbranch@users.noreply.github.com>
* Add test of computed properties
* Remove done TODO
Fixes#33295.
This follows a similar pattern as in #20314 by requiring an explicit
`parent` parameter. Where possible, it uses the appopriate variable at
the call sites.
In several locations there is no context available though (e.g.
inspecting `valueDeclarations`) and we access `.parent` as the code
previously did. From a cursory inspection this seems correct, these
callpaths originate in phases where there must be a `parent` (i.e. in
checker, binder, etc).
Change-Id: I28e4726777b57237bec776e4001e9e69ac591b11
* Add test that fails because file is written multiple times
Reported from #33061
* Handle seenEmittedFiles which was not being set when emit of a file was complete.
It was issue only when errors are reported before emitting (which puts the files into pendingEmit that needs to check only in seenEmittedFiles)
If emit happens before semantic diagnostics query this issue is not repro, because the affected files come into play and those are being set correctly
Fixes#31398
* make baselining source map optional
* Handle emitDeclarationOnly in --build scenario
* Ensure we are using d.ts emit as signature even when --declarationMap is on (map files are emitted before d.ts)
* Move module specifiers to verifyTsBuildOutput
* implement create Hash to be default hashing plus data so we can verify it easily in baseline
* Remove failing baseline
* Accept correct baseline name
* Incrementally parse unchanged ambient declarations
* Re-parse modifiers and decorators so as not to skip errors
* Revert unnecessary change
* Undo the test change that was changed 2 years ago
* Resolve module specifier relative to moduleFile.originalFileName
* Use baseline testing for outputs
* Added skipLibCheck to test
* Switch to using vfs.formatPatch for output
* Fix emit for object rest on a module export
* Add tests for exports of empty object/array binding patterns
* Add delay for exec to ensure diff tool has enough time to start
* Add basic test for current behavior
* Fixes getting destructured variables references(#31922)
* Add test case that renames destructured property
* Fixes missing nested object destrucuturing variable references
* Update LKG
* Add @types/node version bump
* Small paatches/casts to be compatible with latest node
* Accept API baseline update
* Make internal NodeBuffer compatable with latest Buffer
* Why do we even have an internal buffer type
* Sync up internal buffer type better
* Fix lint
* Readd mroe missing Buffer methods
* Decrement line ends if they end with a carriage return.
* Changed handling of newlines and inlined regex operation.
* fixed misname of hintSpan
* added tests
* revert inline of regex match and use getLineEndOfPosition
* fixed lint error and changed a silly thing in tests
* Strip more kinds of timestamps and versions from dockerfile output, rewrite office-ui-fabric dockerfile to use new lerna build system
* Add another filter for just output
* Update user baselines (#23)
* Update user baselines (#24)
* Strip only maybe-present timestamps
* More lenient timestamp filter
* Update user baselines (#25)
* Simplify and enhance vscode dockerfile to use nightly ts in ts extension, too
* Update user baselines (#26)
* Update user baselines (#27)
* Improve typing for Generators and Async Generators
* Add TReturn and TNext to Iterator, IterableIterator, etc.
* Update ts internal Iterator to be assignable from global Iterator
* Make 'done' optional in IteratorYieldResult
* Revert Iterable and IterableIterator to simpler versions plus other fixes
* Add additional inference tests
* Added additional tests
* PR cleanup and minor async iteration type fix
* Updated diagnostics message and added non-strict tests
* Fix expected arity of Iterator/AsyncIterator
* Add support for sharding tests across multiple workers
* Disable unittests when runners are expressly provided (unless they contain the unittest runner)
1. Add a script to generate a sorted list of most costly tests. A tests'
cost is roughly `runtime% / number of edits`. A slow test that's only
been updated once is much less valuable than a slow test that has
been updated 20 times: the latter test is catching more changes in the
type system.
2. Check in the results of running this script. I want to make the
skipping behaviour deterministic and the same for everybody, even though
you may get slightly better performance by examining only *your* test
changes.
3. Add code to skip tests until it reaches a 5% chance of missing an
edit. Right now this provides a 38% speedup.
Still not done:
4. Make this value configurable.
5. Make the CI configuration specify a 0% chance of missing an edit.