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

chore: properly package .ts and .d.ts files #6257

Merged
merged 12 commits into from
Aug 5, 2022

Conversation

BeksOmega
Copy link
Collaborator

@BeksOmega BeksOmega commented Jul 1, 2022

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Resolves

Work on #5857

Proposed Changes

  • Makes it so that .ts sources are included in the /dist (and by extension the package).
  • Makes it so that generated .d.ts files are included in the /dist (and by extension the package).
  • Removes useless imports from the hand written .d.ts files.
  • Modifies the hand written .d.ts files to properly reference the generated ones where applicable.
  • Adds a step to rename all of the references to AnyDuringMigration within the generated .d.ts files to any.

Reason for Changes

  • Prep for sourcemaps.
  • Typings for peeps using typescript.
  • Make what we're doing clearer.
  • Typings for peeps using typescript.
  • Without this step the typings files don't work, because they can't find a reference to AnyDuringMigration, and we can't import any_aliases.d.ts because it's not a module. Plus any is clearer for external devs.

Test Coverage

I did the first step from #6174 but I need to do the rest of it, which is why this is going up as a draft.

Documentation

Additional Information

Docs for removing the useless imports:

  1. Don't use <references path> in your declaration files.
  2. Depending on a UMD library from a UMD library: "Do not use a /// <reference directive to declare a dependency to a UMD library!"
  3. Consuming dependencies. Dependencies are necessary when you actually use the types from dependencies. eg:
import * as moment from "moment";
function getThing(): moment;

@BeksOmega
Copy link
Collaborator Author

Tried linking this to a plugin, and I'm getting the error:

test_bundle.js:2449 Uncaught TypeError: Cannot read properties of undefined (reading 'global')
    at Object.eval (goog.js?67b9:37:28)
    at eval (blockly_compressed.js:13:35)
    at eval (blockly_compressed.js:16:3)
    at ../../../blockly/dist/blockly_compressed.js (test_bundle.js:641:1)
    at __webpack_require__ (test_bundle.js:2446:33)
    at fn (test_bundle.js:2658:21)
    at eval (blockly.js?f917:4:13)
    at eval (blockly.js?f917:2:3)
    at ../../../blockly/dist/blockly.js (test_bundle.js:631:1)
    at __webpack_require__ (test_bundle.js:2446:33)

Not sure what's up, need to debug

@BeksOmega
Copy link
Collaborator Author

Closing this until we resolve the build issues.

@BeksOmega BeksOmega closed this Jul 14, 2022
@BeksOmega BeksOmega reopened this Aug 1, 2022
@BeksOmega BeksOmega marked this pull request as ready for review August 1, 2022 16:53
@BeksOmega BeksOmega requested a review from a team as a code owner August 1, 2022 16:53
@BeksOmega
Copy link
Collaborator Author

Linking this to the https://github.com/johnnyoshika/blockly-typescript-libcheck repo continues to work, but in samples I'm not really getting intellisense.

E.g. if I type Blockly.W I get WorkspaceSvg, we, wheel, wheelEvent_. And notably no Workspace.

I'm not sure if this is a problem with the type defs (since the work in the other repo) or if vscode is just overwhelmed.

@BeksOmega
Copy link
Collaborator Author

BeksOmega commented Aug 2, 2022

I was linking the scroll-options plugin to Blockly, and intellisense was not working, so Maribeth suggested right clicking on blockly/core and selecting Go to Definition to get it to update. I did this, and it took me to core.d.ts... in plugins/block-dynamic-connection (the first plugin directory in plugins), which had the old type def files. I linked that plugin as well, and then the intellisense started working.

I don't think VSCode likes monorepos.

But we know that the typedefs work for intellisense.

I tested both blockly and blockly/core and they both work as expected. blockly gets you Blockly.Javascript, and Blockly.libraryBlocks. While blockly/core does not.

@cpcallen
Copy link
Contributor

cpcallen commented Aug 3, 2022

Looks like this should be replaced by a PR targetting develop now.

@cpcallen cpcallen changed the base branch from ts/migration to develop August 3, 2022 15:28
Copy link
Contributor

@cpcallen cpcallen left a comment

Choose a reason for hiding this comment

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

  • Shouldn't this PR deleting (or at least considerably reducing the size of) typings/blockly.d.ts?

  • Please remove any other vestiges of the old typings system—e.g. references to checkin:typings in package.json and checkinTypings in gulpfile.js.

@BeksOmega
Copy link
Collaborator Author

I decided to use the TYPINGS_BUILD_DIR defined in config since that seemed faster, and as far as I'm concerned this is all dead code walking.

@cpcallen
Copy link
Contributor

cpcallen commented Aug 4, 2022

as I'm concerned this is all dead code walking.

We'll see…

@BeksOmega BeksOmega merged commit 8f0a5ae into google:develop Aug 5, 2022
@BeksOmega BeksOmega mentioned this pull request Aug 8, 2022
4 tasks
@BeksOmega BeksOmega deleted the ts/package branch October 4, 2022 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants