Skip to content

refactor: improved core barrel exports and Application class#10286

Merged
NathanWalker merged 25 commits intobetafrom
feat/types-cleanup
May 17, 2023
Merged

refactor: improved core barrel exports and Application class#10286
NathanWalker merged 25 commits intobetafrom
feat/types-cleanup

Conversation

@rigor789
Copy link
Copy Markdown
Member

@rigor789 rigor789 commented May 9, 2023

PR Checklist

What is the current behavior?

Current type docs issues

image

Note how there's missing type info on the various members.

image

image

What is the new behavior?

Application module is now a class. The ios/android Application classes have been combined with the Application class as subclasses. Cleaned up and simplified Application flows, reduced code duplication between platforms and extracted to the ApplicationCommon class. Improved typings.

The changes cleaned up root barrel exports that were using a const x = {} map to instead export whole modules as a namespace. For example: Utils. This ensures our type docs can be generated properly, as well as reduces the chance of missing a re-export in the main barrel (as it was the case with a few utils, unnoticed).

To make the changes backwards compatible, there's a new application-shims.ts file that maps the old Application module exports to the Application instance. These are correctly marked as deprecated to let users know to migrate away from the deep imports at their convenience.

New type docs example

image

The Utils are now documented as a proper namespace and every exported member has a corresponding linkable entry.

image

image

BREAKING CHANGES:

Application.orientation is no longer a function.

Migration: Remove () from the Application.orientation() call:

import { Application } from "@nativescript/core";

-console.log(Application.orientation());
+console.log(Application.orientation);

Application.systemAppearance is no longer a function.

Migration: Remove () from the Application.systemAppearance() call:

import { Application } from "@nativescript/core";

-console.log(Application.systemAppearance());
+console.log(Application.systemAppearance);

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented May 9, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 6d6d6df. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@cla-bot cla-bot bot added the cla: yes label May 9, 2023
@rigor789 rigor789 changed the title feat: types cleanup [wip] refactor: improved core barrel exports and Application class May 16, 2023
@rigor789 rigor789 marked this pull request as ready for review May 16, 2023 20:01
@NathanWalker NathanWalker self-assigned this May 16, 2023
NathanWalker

This comment was marked as resolved.

@NathanWalker NathanWalker added this to the 8.6 milestone May 17, 2023
@NathanWalker NathanWalker changed the base branch from main to beta May 17, 2023 19:01
@NathanWalker NathanWalker merged commit ec6e2c3 into beta May 17, 2023
@NathanWalker NathanWalker deleted the feat/types-cleanup branch May 17, 2023 19:02
NathanWalker pushed a commit that referenced this pull request May 25, 2023
BREAKING CHANGES:

`Application.orientation` is no longer a function.

Migration: Remove `()` from the `Application.orientation()` call:
```diff
import { Application } from "@nativescript/core";

-console.log(Application.orientation());
+console.log(Application.orientation);
```


`Application.systemAppearance` is no longer a function.

Migration: Remove `()` from the `Application.systemAppearance()` call:
```diff
import { Application } from "@nativescript/core";

-console.log(Application.systemAppearance());
+console.log(Application.systemAppearance);
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants