Skip to content

refractor(core/compiler): hide internal types from generated code - #41119

Closed
petebacondarwin wants to merge 4 commits into
angular:masterfrom
petebacondarwin:compiler-hide-internal-types
Closed

petebacondarwin wants to merge 4 commits into
angular:masterfrom
petebacondarwin:compiler-hide-internal-types

Conversation

@petebacondarwin

@petebacondarwin petebacondarwin commented Mar 8, 2021 •

Copy link
Copy Markdown
Contributor

Fixes #40676

This PR is marked as major because the names of typings that appear in libraries compiled by ngcc have changed. This is not a breaking change for general developing (building and testing applications and libraries) but could affect 3rd party tooling who might have been relying upon these types generated by ngcc. By putting this commit in a major release (i.e. the forthcoming 12.0.0) it gives them time and warning to update the tooling to handle the change if necessary.


This PR sits on top of #41080 so you only need to review from docs(core): fix typos in interface docs onwards.

@google-cla google-cla Bot added the cla: yes label Mar 8, 2021
@petebacondarwin petebacondarwin added compiler: linker target: patch This PR is targeted for the next patch release labels Mar 8, 2021
@petebacondarwin
petebacondarwin force-pushed the compiler-hide-internal-types branch 3 times, most recently from 5b63af6 to e21501d Compare March 9, 2021 12:40
@petebacondarwin petebacondarwin added state: blocked target: major This PR is targeted for the next major release and removed target: patch This PR is targeted for the next patch release labels Mar 9, 2021
@petebacondarwin
petebacondarwin force-pushed the compiler-hide-internal-types branch 3 times, most recently from 531a18a to 5f6faff Compare March 11, 2021 16:09
@jessicajaniuk jessicajaniuk added area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime labels Mar 11, 2021
@ngbot ngbot Bot modified the milestone: Backlog Mar 11, 2021
@petebacondarwin
petebacondarwin force-pushed the compiler-hide-internal-types branch from 5f6faff to 7e7040f Compare March 12, 2021 13:09
@petebacondarwin
petebacondarwin marked this pull request as ready for review March 12, 2021 17:27
@pullapprove
pullapprove Bot requested review from alxhub and mhevery March 12, 2021 17:28
@petebacondarwin
petebacondarwin force-pushed the compiler-hide-internal-types branch 2 times, most recently from 57e7c91 to 68916e4 Compare March 15, 2021 21:34
@petebacondarwin petebacondarwin added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: blocked labels Mar 15, 2021
@petebacondarwin
petebacondarwin requested a review from JoostK March 15, 2021 21:39
@petebacondarwin
petebacondarwin force-pushed the compiler-hide-internal-types branch 2 times, most recently from 66511e3 to 485d849 Compare March 17, 2021 18:31

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This one is interesting. The CtorDependency type isn't exported, nor should it be. Maybe @codeGenApi is more appropriate?

We should at some point include all types that govern the partial compilation output in golden files, in which case this type should be included, but the type itself shouldn't be publicly exported.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So I would leave the @publicApi jsdoc tag on it. This tag really only indicates that it should appear in a golden file.
(The doc-gen doesn't care about it AFAIK.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe only exported types end up in the golden file, the @publicApi marker alone is not sufficient (notice how this PR doesn't update the goldens for @angular/core, whereas CtorDependency wasn't previously public)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, two hurdles must be overcome I believe: it must be exported from the barrel and marked with @publicApi.

@petebacondarwin petebacondarwin removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Mar 17, 2021
The terminology use in the comments did not match the actual
types being referred to.
…ias to `unknown`

These types are only used in the generated typings files to provide
information to the Angular compiler in order that it can compile code
in downstream libraries and applications.

This commit aliases these types to `unknown` to avoid exposing the
previous alias types such as `ɵɵDirectiveDef`, which are internal to
the compiler.
Th `ɵɵFactoryDef` type will appear in published libraries, via their typings
files, to describe what type dependencies a DI factory has. The parameters
on this type are used by tooling such as the Language Service to understand
the DI dependencies of the class being created by the factory.

This commit moves the type to the `public_definitions.ts` file alongside
the other types that have a similar role, and it renames it to `ɵɵFactoryDeclaration`
to align it with the other declaration types such as `ɵɵDirectiveDeclaration`
and so on.
…orDef` in compiled output

The `ɵɵInjectorDef` interface is internal and should not be published publicly
as part of libraries. This commit updates the compiler to render an opaque
type, `ɵɵInjectorDeclaration`, for this instead, which appears in the typings
for compiled libraries.
@petebacondarwin
petebacondarwin force-pushed the compiler-hide-internal-types branch from 2c8419b to e9543b3 Compare March 19, 2021 12:45
@petebacondarwin
petebacondarwin removed the request for review from alxhub March 19, 2021 17:38
@petebacondarwin petebacondarwin added the action: presubmit The PR is in need of a google3 presubmit label Mar 19, 2021
@AndrewKushnir

Copy link
Copy Markdown
Contributor

Presubmit.

@AndrewKushnir AndrewKushnir removed the action: presubmit The PR is in need of a google3 presubmit label Mar 19, 2021
@mhevery mhevery closed this in f2f0eaf Mar 22, 2021
mhevery pushed a commit that referenced this pull request Mar 22, 2021
…ias to `unknown` (#41119)

These types are only used in the generated typings files to provide
information to the Angular compiler in order that it can compile code
in downstream libraries and applications.

This commit aliases these types to `unknown` to avoid exposing the
previous alias types such as `ɵɵDirectiveDef`, which are internal to
the compiler.

PR Close #41119
mhevery pushed a commit that referenced this pull request Mar 22, 2021
Th `ɵɵFactoryDef` type will appear in published libraries, via their typings
files, to describe what type dependencies a DI factory has. The parameters
on this type are used by tooling such as the Language Service to understand
the DI dependencies of the class being created by the factory.

This commit moves the type to the `public_definitions.ts` file alongside
the other types that have a similar role, and it renames it to `ɵɵFactoryDeclaration`
to align it with the other declaration types such as `ɵɵDirectiveDeclaration`
and so on.

PR Close #41119
mhevery pushed a commit that referenced this pull request Mar 22, 2021
…orDef` in compiled output (#41119)

The `ɵɵInjectorDef` interface is internal and should not be published publicly
as part of libraries. This commit updates the compiler to render an opaque
type, `ɵɵInjectorDeclaration`, for this instead, which appears in the typings
for compiled libraries.

PR Close #41119
TeriGlover pushed a commit to TeriGlover/angular that referenced this pull request Apr 5, 2021
The terminology use in the comments did not match the actual
types being referred to.

PR Close angular#41119
TeriGlover pushed a commit to TeriGlover/angular that referenced this pull request Apr 5, 2021
…ias to `unknown` (angular#41119)

These types are only used in the generated typings files to provide
information to the Angular compiler in order that it can compile code
in downstream libraries and applications.

This commit aliases these types to `unknown` to avoid exposing the
previous alias types such as `ɵɵDirectiveDef`, which are internal to
the compiler.

PR Close angular#41119
TeriGlover pushed a commit to TeriGlover/angular that referenced this pull request Apr 5, 2021
…lar#41119)

Th `ɵɵFactoryDef` type will appear in published libraries, via their typings
files, to describe what type dependencies a DI factory has. The parameters
on this type are used by tooling such as the Language Service to understand
the DI dependencies of the class being created by the factory.

This commit moves the type to the `public_definitions.ts` file alongside
the other types that have a similar role, and it renames it to `ɵɵFactoryDeclaration`
to align it with the other declaration types such as `ɵɵDirectiveDeclaration`
and so on.

PR Close angular#41119
TeriGlover pushed a commit to TeriGlover/angular that referenced this pull request Apr 5, 2021
…orDef` in compiled output (angular#41119)

The `ɵɵInjectorDef` interface is internal and should not be published publicly
as part of libraries. This commit updates the compiler to render an opaque
type, `ɵɵInjectorDeclaration`, for this instead, which appears in the typings
for compiled libraries.

PR Close angular#41119
petebacondarwin added a commit to petebacondarwin/angular that referenced this pull request Apr 6, 2021
…claration`

The other similar interfaces were renamed in angular#41119,
but this one was left since it had existed before Ivy. It looks like the interface was
never actually exposed on npm so it is safe to rename this one too.
petebacondarwin added a commit to petebacondarwin/angular that referenced this pull request Apr 6, 2021
…claration`

The other similar interfaces were renamed in angular#41119,
but this one was left since it had existed before Ivy. It looks like the interface was
never actually exposed on npm so it is safe to rename this one too.
zarend pushed a commit that referenced this pull request Apr 7, 2021
…claration` (#41316)

The other similar interfaces were renamed in #41119,
but this one was left since it had existed before Ivy. It looks like the interface was
never actually exposed on npm so it is safe to rename this one too.

PR Close #41316
@angular-automatic-lock-bot

Copy link
Copy Markdown

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 Apr 22, 2021
@petebacondarwin
petebacondarwin deleted the compiler-hide-internal-types branch May 1, 2021 14:17
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: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime cla: yes compiler: linker target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not expose internal types in published APIs (mark them as unknown).

5 participants