Repository navigation
Stop the test template pulling a second set of Parse types - #14
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.