33630dd3ed
The issue is with tsickle type inference and the bug should be assigned to them. The offending code is: ``` function cacheMatchingDirectivesForNode( tNode: TNode, tView: TView, localRefs: string[] | null): void { const exportsMap = localRefs ? {'': -1} : null; // <<<<< ===== OFFENDING LINE const matches = tView.currentMatches = findDirectiveMatches(tNode); if (matches) { for (let i = 0; i < matches.length; i += 2) { const def = matches[i] as DirectiveDef<any>; const valueIndex = i + 1; resolveDirective(def, valueIndex, matches, tView); saveNameToExportMap(matches[valueIndex] as number, def, exportsMap); } } if (exportsMap) cacheMatchingLocalNames(tNode, localRefs, exportsMap); } ``` because it generates invalid js closure code: ``` function cacheMatchingDirectivesForNode(tNode, tView, localRefs) { const /** @type {(null|{: number})} */ exportsMap = localRefs ? { '': -1 } : null; // <<<<< ===== OFFENDING LINE const /** @type {(null|!Array<?>)} */ matches = tView.currentMatches = findDirectiveMatches(tNode); if (matches) { for (let /** @type {number} */ i = 0; i < matches.length; i += 2) { const /** @type {!tsickle_forward_declare_11.DirectiveDef<?>} */ def = /** @type {!tsickle_forward_declare_11.DirectiveDef<?>} */ (matches[i]); const /** @type {number} */ valueIndex = i + 1; resolveDirective(def, valueIndex, matches, tView); saveNameToExportMap(/** @type {number} */ (matches[valueIndex]), def, exportsMap); } } if (exportsMap) cacheMatchingLocalNames(tNode, localRefs, exportsMap); } ``` The workaround is to declare the type explicitly such as: ``` const exportsMap: ({[key:string]:number}|null) = localRefs ? {'': -1} : null; ``` which than generates valid closure code: ``` const /** @type {(null|!Object<string,number>)} */ exportsMap = localRefs ? { '': -1 } : null; ``` PR Close #23379 |
||
---|---|---|
.circleci | ||
.github | ||
aio | ||
docs | ||
integration | ||
modules | ||
packages | ||
scripts | ||
tools | ||
.bowerrc | ||
.clang-format | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.mailmap | ||
.nvmrc | ||
.pullapprove.yml | ||
.travis.yml | ||
BUILD.bazel | ||
CHANGELOG.md | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
LICENSE | ||
README.md | ||
WORKSPACE | ||
bower.json | ||
browser-providers.conf.js | ||
build.sh | ||
gulpfile.js | ||
karma-js.conf.js | ||
package.json | ||
protractor-e2e.conf.js | ||
protractor-examples-e2e.conf.js | ||
protractor-perf.conf.js | ||
shims_for_IE.js | ||
test-events.js | ||
test-main.js | ||
test.sh | ||
tslint.json | ||
yarn.lock | ||
yarn.lock.readme.md |
README.md
Safari (7+), iOS (7+) and IE mobile (11) are tested on BrowserStack.
Angular
Angular is a development platform for building mobile and desktop web applications using Typescript/JavaScript and other languages.
Quickstart
Want to help?
Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the hotlist: community-help.