Is the wrapping of Vinyl file to class is Valid? #2700
              
                Unanswered
              
          
                  
                    
                      TokugawaTakeshi
                    
                  
                
                  asked this question in
                General
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Below recipe from the Vinyl documentation is a valid JavaScript, but not valid TypeScript:
In the TypeScript,
extends VinylcausesTS2510: Base constructors must all have the same return type.error.This problem has been explained in How to access to interface or type alias which has not been explicitly exported in TypeScript type definitions? topic in StackOverflow.
Well, I understand if you want to use JavaScript and basic language for the development and cannot require from you the full migration to TypeScript. What I want in this discussion is to confirm one thing - it is safe to create the class extending the Vinyl file like below?
I tried to avoid the routines like creating of
builtInPropsvariable and adding ofisCustomPropmethod from the example from the Vinyl documentation, so I have not passed the wholeinitialFileto the constructor of the superclass.Well, the above class is still invalid TypeScript, but what I tried to confirm for now is does this class have some undesirable side effects.
This is the end of the question itself.
If you want to know my motivation, I'll explain it below.
First, if to use the class, will be too easy to filter the subtypes of
Vinylbyfile instanceof MarkupVinylFile.The creating of the TypeGuard like
is too much routines.
Second, both adding of new properties to Vinyl file and accessing to them is not type-safe:
The creating of the class as
MarkupVinylFilefully solves this problem.Beta Was this translation helpful? Give feedback.
All reactions