File tree Expand file tree Collapse file tree 3 files changed +10
-3
lines changed
Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -1877,7 +1877,7 @@ class ParseObject<T extends Attributes = Attributes> {
18771877 * @static
18781878 * @returns {Parse.Object } A Parse.Object reference.
18791879 */
1880- static createWithoutData ( id : string ) : ParseObject {
1880+ static createWithoutData < T extends ParseObject > ( this : new ( ... args : any [ ] ) => T , id : string ) : T {
18811881 const obj = new this ( ) ;
18821882 obj . id = id ;
18831883 return obj ;
Original file line number Diff line number Diff line change @@ -894,7 +894,7 @@ declare class ParseObject<T extends Attributes = Attributes> {
894894 * @static
895895 * @returns {Parse.Object } A Parse.Object reference.
896896 */
897- static createWithoutData ( id : string ) : ParseObject ;
897+ static createWithoutData < T extends ParseObject > ( this : new ( ... args : any [ ] ) => T , id : string ) : T ;
898898 /**
899899 * Creates a new instance of a Parse Object from a JSON representation.
900900 *
Original file line number Diff line number Diff line change @@ -42,6 +42,14 @@ async function test_object() {
4242 // Create a new instance of that class.
4343 const gameScore = new GameScore ( ) ;
4444
45+ // Expect that `createWithoutData` returns the types for the same classes (not generic ParseObjects)
46+ // $ExpectType Game
47+ Game . createWithoutData ( 'someid' ) ;
48+ // $ExpectType GameScore
49+ GameScore . createWithoutData ( 'scoreid' ) ;
50+ // $ExpectType ParseUser<Attributes>
51+ Parse . User . createWithoutData ( 'someuser' ) ;
52+
4553 gameScore . set ( 'score' , 1337 ) ;
4654 gameScore . set ( 'playerName' , 'Sean Plott' ) ;
4755 gameScore . set ( 'cheatMode' , false ) ;
@@ -2375,4 +2383,3 @@ function testInitialize() {
23752383 // Node - 1 param (should also work since javaScriptKey is optional in node)
23762384 ParseNode . initialize ( 'appId' ) ;
23772385}
2378-
You can’t perform that action at this time.
0 commit comments