Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(language-service): Simplify resolution logic in banner (#34262)
Due to a bug in the existing banner, `typescript` module was require-d instead of reusing the module passed in from tsserver. This bug is caused by some source files in language-service that imports `typescript` instead of `typescript/lib/tsserverlibrary`. This is not an unsupported use case, it's just that when typescript is resolved in the banner we have to be very careful about which modules to "require". The convoluted logic in the banner makes it very hard to detect anomalies. This commit cleans it up and removes a lot of unneeded code. This commit also removes `ts` import in typescript_host.ts and use `tss` instead to make it less confusing. PR Close #34262
- Loading branch information
1 parent
6c70ba7
commit 7dfd327
Showing
4 changed files
with
57 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @license Angular v0.0.0-PLACEHOLDER | ||
* Copyright Google Inc. All Rights Reserved. | ||
* License: MIT | ||
*/ | ||
|
||
let $deferred; | ||
function define(modules, callback) { | ||
$deferred = {modules, callback}; | ||
} | ||
module.exports = function(provided) { | ||
const ts = provided['typescript']; | ||
if (!ts) { | ||
throw new Error('Caller does not provide typescript module'); | ||
} | ||
const results = {}; | ||
const resolvedModules = $deferred.modules.map(m => { | ||
if (m === 'exports') { | ||
return results; | ||
} | ||
if (m === 'typescript' || m === 'typescript/lib/tsserverlibrary') { | ||
return ts; | ||
} | ||
return require(m); | ||
}); | ||
$deferred.callback(...resolvedModules); | ||
return results; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters