Skip to content

Support disabling weak type checking #16968

Closed

Description

@smhc

TypeScript Version: 2.4.1

Expected behavior:

Can compile projects using third party dependencies that have not been upgraded to support strict weak type checks in typescript 2.4.1.

Actual behavior:

Projects that depend on third party libraries that have 'weak type' errors cause compilation errors. The proposed workarounds are not possible when the type definitions reside in third party code.

Proposed Solution:

A flag to disable strict weak type checks.
Even better would be the ability to enable/disable similar strict checks for third party libraries (node_modules) selectively.
The dependency may very well have a bug or poor definition, and it may or may not get fixed. But even if it does get fixed, the fix may be in a version that is impractical to upgrade to.

I hit the issue with protractor and was fortunately able to upgrade to a version that didn't have regressions. I am now hitting the problem with ag-grid: ag-grid/ag-grid#1745
This one doesn't seem like a 'bug', but rather a poor definition. If it is fixed, I may not be able to upgrade to the version it is fixed in.

Activity

  1. smhc commented on Jul 6, 2017

    @smhc
    Author

    Some further discussion of this is located here: ag-grid/ag-grid#1708

    I thought weak type 'implements' may still be useful for code like the below. However typescript doesn't actually pick this up as an error. I think it would be helpful if it did, and weak type implements should be allowed if so.

    // Library code
    
    interface IDisposable {
        // implement if you want custom dispose code
        dispose?: () => boolean;
    }
    
    class DefaultThing implements IDisposable {
        // doesn't require custom dispose, but extenders should implement it correctly if they do
        public work(): number {
            return 0;
        }
    }
    
    // Project code
    
    class MyThing extends DefaultThing {
        // want to inherit 'work()', but also the type checking of 'dispose(): boolean'
        public dispose(): string {  // want an error here
            return '';
        }
    }
  2. RyanCavanaugh commented on Jul 6, 2017

    @RyanCavanaugh
    Member

    The referenced issue has an explanation from me of what you should be doing in that case.

  3. smhc commented on Jul 7, 2017

    @smhc
    Author

    Closing this issue as it is discussed elsewhere.
    Will wait to see if many others are hit by the same problem that prevents being able to upgrade before following it up further.

  4. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions