-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f32a229
fix(tests): Use tsc-compiled base.js to allow use of goog.js
cpcallen 5c3d72b
docs(build): JSDoc update for JSCOMP_WARNING
cpcallen 70516d5
refactor(utils): Convert utils/deprecation.js to TypeScript
cpcallen 6484e42
chore(utils): Update utils/deprecation.ts from MigranTS output
cpcallen ca23daa
feat(build): clang-format .ts files
cpcallen 412e848
fix(build): Fix sources for advanced compilation test
cpcallen 2a07141
fix(build): Disable checkTypes diagnostic group
cpcallen 284103e
chore(utils): Use @internal where we previously used @package
cpcallen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -174,7 +174,7 @@ var JSCOMP_ERROR = [ | |
// 'accessControls', // Deprecated; means same as visibility. | ||
'checkPrototypalTypes', | ||
'checkRegExp', | ||
'checkTypes', | ||
// 'checkTypes', // Disabled; see note in JSCOMP_OFF. | ||
'checkVars', | ||
'conformanceViolations', | ||
'const', | ||
|
@@ -198,7 +198,7 @@ var JSCOMP_ERROR = [ | |
// 'missingSourcesWarnings', // Group of several other options. | ||
'moduleLoad', | ||
'msgDescriptions', | ||
'nonStandardJsDocs', | ||
// 'nonStandardJsDocs', // Disabled; see note in JSCOMP_OFF. | ||
// 'partialAlias', // Don't want this to be an error yet; only warning. | ||
// 'polymer', // Not applicable. | ||
// 'reportUnknownTypes', // VERY verbose. | ||
|
@@ -222,15 +222,36 @@ var JSCOMP_ERROR = [ | |
/** | ||
* Closure compiler diagnostic groups we want to be treated as warnings. | ||
* These are effected when the --debug or --strict flags are passed. | ||
* | ||
* For most (all?) diagnostic groups this is the default level, so | ||
* it's generally sufficient to remove them from JSCOMP_ERROR. | ||
*/ | ||
var JSCOMP_WARNING = [ | ||
]; | ||
|
||
/** | ||
* Closure compiler diagnostic groups we want to be ignored. | ||
* These suppressions are always effected by default. | ||
* Closure compiler diagnostic groups we want to be ignored. These | ||
* suppressions are always effected by default. | ||
* | ||
* Make sure that anything added here is commented out of JSCOMP_ERROR | ||
* above, as that takes precedence.) | ||
*/ | ||
var JSCOMP_OFF = [ | ||
/* The removal of Closure type system types from our JSDoc | ||
* annotations means that the closure compiler now generates certain | ||
* diagnostics because it no longer has enough information to be | ||
* sure that the input code is correct. The following diagnostic | ||
* groups are turned off to suppress such errors. | ||
* | ||
* When adding additional items to this list it may be helpful to | ||
* search the compiler source code | ||
* (https://github.com/google/closure-compiler/) for the JSC_* | ||
* disagnostic name (omitting the JSC_ prefix) to find the corresponding | ||
* DiagnosticGroup. | ||
*/ | ||
'checkTypes', | ||
'nonStandardJsDocs', // Due to @internal | ||
|
||
/* In order to transition to ES modules, modules will need to import | ||
* one another by relative paths. This means that the previous | ||
* practice of moving all source files into the same directory for | ||
|
@@ -269,12 +290,8 @@ function buildJavaScript(done) { | |
* suite. | ||
*/ | ||
function buildDeps(done) { | ||
const closurePath = argv.closureLibrary ? | ||
'node_modules/google-closure-library/closure/goog' : | ||
'closure/goog'; | ||
|
||
const roots = [ | ||
closurePath, | ||
path.join(TSC_OUTPUT_DIR, 'closure', 'goog', 'base.js'), | ||
TSC_OUTPUT_DIR, | ||
'blocks', | ||
'generators', | ||
|
@@ -430,15 +447,15 @@ return ${exportsExpression}; | |
* @return {{chunk: !Array<string>, js: !Array<string>}} The chunking | ||
* information, in the same form as emitted by | ||
* closure-calculate-chunks. | ||
* | ||
* TODO(cpcallen): maybeAddClosureLibrary? Or maybe remove base.js? | ||
*/ | ||
function getChunkOptions() { | ||
if (argv.compileTs) { | ||
chunks[0].entry = path.join(TSC_OUTPUT_DIR, chunks[0].entry); | ||
} | ||
Comment on lines
452
to
454
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
const basePath = | ||
path.join(TSC_OUTPUT_DIR, 'closure', 'goog', 'base_minimal.js'); | ||
const cccArgs = [ | ||
'--closure-library-base-js-path ./closure/goog/base_minimal.js', | ||
`--closure-library-base-js-path ./${basePath}`, | ||
`--deps-file './${DEPS_FILE}'`, | ||
...(chunks.map(chunk => `--entrypoint '${chunk.entry}'`)), | ||
]; | ||
|
@@ -545,7 +562,11 @@ function compile(options) { | |
language_out: 'ECMASCRIPT5_STRICT', | ||
jscomp_off: [...JSCOMP_OFF], | ||
rewrite_polyfills: true, | ||
hide_warnings_for: 'node_modules', | ||
// N.B.: goog.js refers to lots of properties on goog that are not | ||
// declared by base_minimal.js, while if you compile against | ||
// base.js instead you will discover that it uses @deprecated | ||
// inherits, forwardDeclare etc. | ||
hide_warnings_for: ['node_modules', 'build/src/closure/goog/goog.js'], | ||
define: ['COMPILED=true'], | ||
}; | ||
if (argv.debug || argv.strict) { | ||
|
@@ -597,11 +618,10 @@ function buildCompiled() { | |
* closure compiler's ADVANCED_COMPILATION mode. | ||
*/ | ||
function buildAdvancedCompilationTest() { | ||
const coreSrcs = argv.compileTs ? | ||
TSC_OUTPUT_DIR + '/core/**/*.js' : 'core/**/*.js'; | ||
const srcs = [ | ||
'closure/goog/base_minimal.js', | ||
coreSrcs, | ||
TSC_OUTPUT_DIR + '/closure/goog/base_minimal.js', | ||
TSC_OUTPUT_DIR + '/closure/goog/goog.js', | ||
TSC_OUTPUT_DIR + '/core/**/*.js', | ||
'blocks/**/*.js', | ||
'generators/**/*.js', | ||
'tests/compile/main.js', | ||
|
@@ -668,7 +688,10 @@ function cleanBuildDir(done) { | |
* Runs clang format on all files in the core directory. | ||
*/ | ||
function format() { | ||
return gulp.src(['core/**/*.js', 'blocks/**/*.js'], {base: '.'}) | ||
return gulp.src([ | ||
'core/**/*.js', 'core/**/*.ts', | ||
'blocks/**/*.js', 'blocks/**/*.ts' | ||
], {base: '.'}) | ||
.pipe(clangFormatter.format('file', clangFormat)) | ||
.pipe(gulp.dest('.')); | ||
}; | ||
|
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
withinternal
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.
nonStandardJsDocs
. But no problem.@package
annotation was deleted by the tooling that converted this file to TS, not by me. This will be a headache…