Skip to content
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

Ensure packages can be built with TypeScript strict flag #30993

Closed

Conversation

devversion
Copy link
Member

@devversion devversion commented Jun 12, 2019

Implemented as part of FW-1265. See individual commits for description of changes.

@devversion devversion force-pushed the refactor/core-wip-strict-flag branch 2 times, most recently from 4a1d923 to f93e879 Compare June 12, 2019 09:14
@devversion devversion added area: core Issues related to the framework runtime action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 12, 2019
@ngbot ngbot bot modified the milestone: needsTriage Jun 12, 2019
@devversion devversion force-pushed the refactor/core-wip-strict-flag branch from f93e879 to fd10216 Compare June 12, 2019 09:23
@devversion devversion marked this pull request as ready for review June 12, 2019 09:26
@devversion devversion requested review from a team as code owners June 12, 2019 09:26
@devversion devversion force-pushed the refactor/core-wip-strict-flag branch from fd10216 to f3a7180 Compare June 12, 2019 10:52
@devversion devversion requested a review from a team as a code owner June 12, 2019 10:52
Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

packages/core/src/util/decorators.ts Outdated Show resolved Hide resolved
packages/core/src/render3/di.ts Show resolved Hide resolved
packages/core/src/linker/ng_module_factory_registration.ts Outdated Show resolved Hide resolved
packages/core/src/di/reflective_provider.ts Show resolved Hide resolved
packages/core/src/debug/debug_node.ts Outdated Show resolved Hide resolved
packages/compiler/src/render3/view/template.ts Outdated Show resolved Hide resolved
packages/tsconfig-build-strict.json Outdated Show resolved Hide resolved
packages/BUILD.bazel Outdated Show resolved Hide resolved
@devversion devversion force-pushed the refactor/core-wip-strict-flag branch from f3a7180 to 0ef9400 Compare June 12, 2019 16:31
@devversion devversion added state: WIP and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 13, 2019
@devversion devversion force-pushed the refactor/core-wip-strict-flag branch from 0ef9400 to 7a51f10 Compare June 13, 2019 20:22
@devversion devversion requested review from a team as code owners June 13, 2019 20:22
@devversion devversion force-pushed the refactor/core-wip-strict-flag branch from 7a51f10 to c30cdbf Compare June 13, 2019 20:57
mhevery pushed a commit that referenced this pull request Jul 18, 2019
…30993)

As part of FW-1265, the `@angular/common` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close #30993
mhevery pushed a commit that referenced this pull request Jul 18, 2019
…30993)

As part of FW-1265, the `@angular/upgrade` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close #30993
mhevery pushed a commit that referenced this pull request Jul 18, 2019
…#30993)

As part of FW-1265, the `@angular/platform-browser` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close #30993
mhevery pushed a commit that referenced this pull request Jul 18, 2019
As part of FW-1265, the `@angular/router` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close #30993
mhevery pushed a commit that referenced this pull request Jul 18, 2019
…0993)

As part of FW-1265, the `@angular/forms` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close #30993
mhevery pushed a commit that referenced this pull request Jul 18, 2019
… flag (#30993)

As part of FW-1265, the `@angular/service-worker` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close #30993
mhevery pushed a commit that referenced this pull request Jul 18, 2019
Fixes all TypeScript failures caused by enabling the `--strict`
flag for test source files. We also want to enable the strict
options for tests as the strictness enforcement improves the
overall codehealth, unveiled common issues and additionally it
allows us to enable `strict` in the `tsconfig.json` that is picked
up by IDE's.

PR Close #30993
mhevery pushed a commit that referenced this pull request Jul 18, 2019
…with strictFunctionTypes (#30993)

Currently developers can use the `By` class to construct common
`DebugElement` query predicates. e.g. `By.directive(MyDirective)`.

The `directive()` and `all()` predicates are currently returning
a predicate that works for `DebugElement` nodes. This return type
is too strict since the predicate is not specific to `DebugElement`
instances and can also apply to `DebugNode` instances.

Meaning that developers are currently able to use the `directive()`
predicate when using `queryAllNodes()`. This is a common practice
but will break when the project is compiled with TypeScript's
`--strictFunctionTypes` flag as the `DebugElement` predicate type
is not assignable to predicates for `DebugNode`. In order to make
these predicates usable with `--strictFuntionTypes` enabled, we
adjust the predicate type to reflect what is actually needed for
evaluation of the predicate.

PR Close #30993
mhevery pushed a commit that referenced this pull request Jul 18, 2019
…0993)

As part of FW-1265, the `zone.js` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close #30993
devversion added a commit to devversion/angular that referenced this pull request Aug 2, 2019
Follow-up to angular#30993 where we build all Angular packages with
the TypeScript `--strict` flag. The flag improves overall code
health and also helps us catch issues easier.
devversion added a commit to devversion/angular that referenced this pull request Aug 13, 2019
…ar#31967)

Follow-up to angular#30993 where we build all Angular packages with
the TypeScript `--strict` flag. The flag improves overall code
health and also helps us catch issues easier.

PR Close angular#31967
kara pushed a commit that referenced this pull request Aug 13, 2019
Follow-up to #30993 where we build all Angular packages with
the TypeScript `--strict` flag. The flag improves overall code
health and also helps us catch issues easier.

PR Close #31967
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
…ular#30993)

As part of FW-1265, the `@angular/core` package is made compatible
with the TypeScript `--strict` flag. This already unveiled a few bugs,
so the strictness flag seems to help with increasing the overall code health.

Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close angular#30993
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
…ngular#30993)

As part of FW-1265, the `@angular/compiler` package is made compatible
with the TypeScript `--strict` flag. This already unveiled a few bugs,
so the strictness flag seems to help with increasing the overall code health.

Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close angular#30993
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
Fixes the remaining TypeScript --strict flag failures for source
files which are not part of any specific release package.

PR Close angular#30993
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
)

Currently the `ɵɵdefineComponent` method has incorrect type
definitions the `directives` and `pipes` metadata property.

The incorrect types allow developers to pass in already instantiated
`DirectiveDef` or `ComponentDef` objects. This can cause unexpected
failures because the definition internally only expects `Type` objects
and now incorrectly tries to read the `ngDirectiveDef` or `ngComponentDef`
of existing definitions.

This issue has been unveiled by enabling the strict function parameter
types flag, where the directive definitions are determined from each array
element in the `directives` or `pipes` property (which can throw).

PR Close angular#30993
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
…gular#30993)

In View Engine, developers can pass bootstrap and entry components
as nested arrays. e.g.

```ts
export const MyOtherEntryComponents = [A, B, C]

@NgModule({
  entryComponents: [MyComp, MyOtherEntryComponents]
})
```

Currently using nested arrays for these properties causes
unexpected errors to be reported in Ivy since the semantic
NgModule checks aren't properly recursing into the nested
entry/bootstrap components. This issue has been unveiled by
enabling the strict function parameter checks.

PR Close angular#30993
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
…ngular#30993)

As part of FW-1265, the `@angular/common` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close angular#30993
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
…ngular#30993)

As part of FW-1265, the `@angular/upgrade` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close angular#30993
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
…angular#30993)

As part of FW-1265, the `@angular/platform-browser` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close angular#30993
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
…30993)

As part of FW-1265, the `@angular/router` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close angular#30993
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
…gular#30993)

As part of FW-1265, the `@angular/forms` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close angular#30993
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
… flag (angular#30993)

As part of FW-1265, the `@angular/service-worker` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close angular#30993
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
…0993)

Fixes all TypeScript failures caused by enabling the `--strict`
flag for test source files. We also want to enable the strict
options for tests as the strictness enforcement improves the
overall codehealth, unveiled common issues and additionally it
allows us to enable `strict` in the `tsconfig.json` that is picked
up by IDE's.

PR Close angular#30993
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
…with strictFunctionTypes (angular#30993)

Currently developers can use the `By` class to construct common
`DebugElement` query predicates. e.g. `By.directive(MyDirective)`.

The `directive()` and `all()` predicates are currently returning
a predicate that works for `DebugElement` nodes. This return type
is too strict since the predicate is not specific to `DebugElement`
instances and can also apply to `DebugNode` instances.

Meaning that developers are currently able to use the `directive()`
predicate when using `queryAllNodes()`. This is a common practice
but will break when the project is compiled with TypeScript's
`--strictFunctionTypes` flag as the `DebugElement` predicate type
is not assignable to predicates for `DebugNode`. In order to make
these predicates usable with `--strictFuntionTypes` enabled, we
adjust the predicate type to reflect what is actually needed for
evaluation of the predicate.

PR Close angular#30993
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
…gular#30993)

As part of FW-1265, the `zone.js` package is made compatible
with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close angular#30993
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
…ar#31967)

Follow-up to angular#30993 where we build all Angular packages with
the TypeScript `--strict` flag. The flag improves overall code
health and also helps us catch issues easier.

PR Close angular#31967
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime cla: yes target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants