-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(build): Support TypeScript in core/
#6220
Conversation
The Closure Compiler complains if you try to feed it a file named goog.js which is not in the same directory as the Closure Library's base.js. Since tsc will "compile" goog.js when it encounters an "import ... from '.../goog.js'", it is necessary to also have tsc "compile" base.js and base_minimal.js, so they will come from the same directory. This necessitates some updates to paths in
This was done manually for test/proving purposes and might need to be corrected based on what MigranTS generated.
This manually applies certain changes from BeksOmega's ts/migration2 branch, but notably: - I did not apply the reordering of the doc comments at the top. - I applied the deletion of types and @Package from the JSDoc. - I preserved the import goog and goog.declareModuleId lines. - I have applied a whitespace change on line 37 which violates the styleguide; I want to figure out why clang-format is not fixing this.
And fix formatting issues introduced by MigranTS in deprecation.ts.
Hmm: good thing I accidentally made this a draft PR, because CI has caught a problem that I missed: it did pass
I think this is basically expected (:weeps in tsicle:) but we should probably think about exactly how we want to deal with it. |
* @alias Blockly.utils.deprecation.warn | ||
* @package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace package
with internal
rather than deleting it: https://api-extractor.com/pages/tsdoc/tag_internal/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Done.
- Turns out this involves suppressing
nonStandardJsDocs
. But no problem. - Note that the
@package
annotation was deleted by the tooling that converted this file to TS, not by me. This will be a headache…
Christopher and I discussed this morning and agreed to turn off error classes by adding them to JSCOMP_OFF as they turn up. JSDoc and TSDoc are not the same. However, Trying to keep all of the comments compatible with both systems adds overhead and makes it take longer to get to where Given that we currently have a pile of |
I'm not sure why this didn't fail on my local machine previously; perhaps it succeeded only because of leftover files and would have failed if I'd run npm run clean.
Unfortunately TSC doesn't output type information in a form that Closure Compiler can understand, so the latter raises errors for situations like omitting an optional parameter. We may have to turn off more diagnostics in future, but for now this is sufficient.
Per comments on PR google#6220. This requires that we disable the nonStandardJsDocs diagnostic.
OK, looks like we're good at last. I note that
(Previously it only complained about bounded generics.) This tool appears to lack almost any control over error generation, which is annoying, but AFAIK these messages are harmless. I will see about suppressing—via |
if (argv.compileTs) { | ||
chunks[0].entry = path.join(TSC_OUTPUT_DIR, chunks[0].entry); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have deleted this in this PR. Fortunately noticed by an external contributor and corrected in #6431.
The basics
npm run format
andnpm run lint
The details
Resolves
Closes #5892
Proposed Changes
core/
by making a small tweak to how the Closure Library is presented to Closure Compiler.core/utils/deprecation.js
to TypeScript.clang-format
ting of.ts
files incore/
andblocks/
.Behaviour Before Change
Closure Compiler is fed files in
closure/goog/
as input. If a.ts
fileimport
sclosure/goog/goog.js
, this causes the compiler to complain because the import will, after compilation bytsc
, point tobuild/src/closure/goog
, and CC won't let you name an input filegoog.js
unless it is in the same directory asbase.js
(or alternatively ourbase_minimal.js
).Behaviour After Change
All of
closure/goog/*.js
is passed throughtsc
and ends up inbuild/src/closure/goog/
, so CC is readinggoog.js
andbase_minimal.js
from the same directory, making it happy.Reason for Changes
See above.
Test Coverage
PassesSee comments below.npm test
.No changes to manual test procedures expected.
Additional Information
There are some issues with MigranTS output which means we cannot blindly copy it over the previous .js files—see individual commit messages for details.