Skip to content

Stop the test template pulling a second set of Parse types - #14

Merged
walhalabi-code merged 1 commit into
mainfrom
fix/parse-type-conflict
Aug 31, 2026
Merged

walhalabi-code merged 1 commit into
mainfrom
fix/parse-type-conflict

Conversation

@walhalabi-code

Copy link
Copy Markdown
Owner

The test file added in 3.0.2 began with a typed import:

import Parse from 'parse/node';

That put the type definitions the parse package ships into a project whose every other file uses the @types/parse global. The two disagree - getSessionToken() is string in one and string | null in the other - so a project could see errors about its own code that were really a clash between two definitions of the same API, in a file the user never opened.

tsc tolerated it, which is why it was not caught: the generated project compiled cleanly the whole time. Editors need not be so forgiving, and an error that points at your code while originating somewhere else is the hardest kind to act on.

Now a require, which sets the global without introducing a second source of types. Parse in that file means what it means everywhere else. The SDK still has to be on the global before any model is imported, because @ParseClass registers the subclass while the module is evaluated - the require does that just as well.

Verified: a generated project compiles, its five tests pass, and no file imports parse's own types.

The test file added in 3.0.2 began with a typed import:

  import Parse from 'parse/node';

That put the type definitions the parse package ships into a project whose every
other file uses the @types/parse global. The two disagree - getSessionToken() is
string in one and string | null in the other - so a project could see errors
about its own code that were really a clash between two definitions of the same
API, in a file the user never opened.

tsc tolerated it, which is why it was not caught: the generated project compiled
cleanly the whole time. Editors need not be so forgiving, and an error that
points at your code while originating somewhere else is the hardest kind to act
on.

Now a require, which sets the global without introducing a second source of
types. Parse in that file means what it means everywhere else. The SDK still has
to be on the global before any model is imported, because @ParseClass registers
the subclass while the module is evaluated - the require does that just as well.

Verified: a generated project compiles, its five tests pass, and no file imports
parse's own types.
@walhalabi-code
walhalabi-code merged commit 250cea2 into main Aug 31, 2026
5 checks passed
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.

1 participant